1.Easy
What defines a binary tree?
- AEvery node stores a binary number
- BThe tree has exactly two levels
- CEvery node has at most two children
- DEvery node has exactly two children
2.Easy
Which operation is O(1) for an array but O(n) for a singly linked list?
- AReading the first element
- BInserting at the head
- CAccessing the element at index i
- DRemoving the head element
3.Easy
A hash table stores data as:
- AA tree with ordered keys
- BA sorted list only
- CA fixed-length string
- DKey–value pairs located by a hash function
4.Medium
What is the cost of inserting an element in the middle of an array of n elements?
- AO(1), because the index is known
- BO(n²), because each element moves n times
- CO(log n), because of binary search
- DO(n), because later elements must shift
5.Medium
What is the time complexity of searching for a key in a balanced binary search tree?
- AO(n log n)
- BO(n)
- CO(log n)
- DO(1)
6.Medium
A binary tree has root 1 with left child 2 and right child 3; node 2 has children 4 (left) and 5 (right). What is the postorder traversal?
- A1 2 4 5 3
- B5 4 3 2 1
- C4 5 2 3 1
- D4 2 5 1 3
7.Hard
What guarantee do the red-black tree rules give about the height of a tree with n keys?
- AThe height is at most log2 n + 1
- BThe height is at most n / 2
- CThe height is at most 2 log2(n + 1)
- DThe height is exactly log2 n
8.Hard
In a hash table using open addressing, why is deletion often done with a "tombstone" marker?
- ATombstones speed up hashing
- BIt makes the table sorted
- CDeleted keys must be kept forever for security, so slots can never be reused
- DEmptying the slot could break the probe sequence for other keys
Answer key
- 1. C · Every node has at most two children
- 2. C · Accessing the element at index i
- 3. D · Key–value pairs located by a hash function
- 4. D · O(n), because later elements must shift
- 5. C · O(log n)
- 6. C · 4 5 2 3 1
- 7. C · The height is at most 2 log2(n + 1)
- 8. D · Emptying the slot could break the probe sequence for other keys
Full step-by-step solutions: practise this topic on examproblems.com.