1.Easy
What is the main difference between a static array and a dynamic array?
- AA static array allows slower index access
- BA dynamic array can grow by moving to a larger block of memory
- CA static array can only store numbers
- DA dynamic array stores its elements in linked nodes so it can grow one at a time
2.Easy
What does each node in a doubly linked list contain?
- AData and two pointers, one to the next node and one to the node after that
- BTwo copies of the data and one pointer
- CData, a pointer to the next node and a pointer to the previous node
- DData and a pointer to the next node only
3.Easy
Which operation is slow in an array but fast at the head of a linked list?
- AAccessing the 5th element
- BInserting at the beginning
- CReading the last element by index
- DFinding the length of a fixed array
4.Medium
The keys 50, 30, 70, 20, 40 are inserted in this order into an empty binary search tree. What is the left child of 30?
- A40
- B50
- C70
- D20
5.Medium
You have a reference to a node in the middle of a list. In which list can you remove it in O(1)?
- AA dynamic array
- BA singly linked list
- CA sorted array
- DA doubly linked list
6.Medium
AVL trees and red-black trees guarantee:
- AThat keys are stored in insertion order
- BO(log n) height through rebalancing
- CThat no node has two children
- DConstant-time search in every case
7.Hard
Deleting a node with two children from a binary search tree is usually done by:
- ASwapping it with the root
- BRemoving the whole subtree
- CRebuilding the subtree below it from scratch and reinserting every key it contained
- DReplacing it with its in-order successor (or predecessor) and deleting that node
8.Hard
An object is stored as a key in a hash map, and then a field used by its hash function is changed. What is the likely result?
- ANothing changes, because a key's hash is computed only once when the program starts
- BLooking up the object may fail because it sits in the bucket for its old hash
- CThe map automatically moves the key to its new bucket
- DThe map throws an error at the moment the field changes
Answer key
- 1. B · A dynamic array can grow by moving to a larger block of memory
- 2. C · Data, a pointer to the next node and a pointer to the previous node
- 3. B · Inserting at the beginning
- 4. D · 20
- 5. D · A doubly linked list
- 6. B · O(log n) height through rebalancing
- 7. D · Replacing it with its in-order successor (or predecessor) and deleting that node
- 8. B · Looking up the object may fail because it sits in the bucket for its old hash
Full step-by-step solutions: practise this topic on examproblems.com.