1.Easy
The depth of a node in a tree is:
- AThe number of nodes in its subtree
- BThe number of children of that node
- CThe number of edges from that node to the deepest leaf
- DThe number of edges from the root to that node
2.Easy
Where is the smallest element of a binary min-heap found?
- AIn the leftmost leaf
- BAt the root
- CIn the last array position
- DIn any leaf, which must be searched
3.Easy
How are the elements of an array stored in memory?
- AIn random locations chosen by a hash
- BIn one contiguous block, one after another
- CIn a tree of memory pages
- DScattered, linked by pointers
4.Medium
How do you find the minimum key in a binary search tree?
- AFollow left children from the root until there is no left child
- BLook at the root only
- CFollow right children from the root until there is no right child
- DVisit every leaf and compare them
5.Medium
In a binary min-heap stored in an array (index starting at 0), the children of the node at index i are at:
- Ai + 1 and i + 2
- Bi/2 and i/2 + 1
- C2i + 1 and 2i + 2
- D2i and 2i + 1
6.Medium
An in-order traversal of a binary search tree visits the keys in:
- AAscending sorted order
- BDescending order always
- CLevel order
- DInsertion order
7.Hard
Which structure lets you compute the maximum of every window of size k in an array in O(n) total?
- AA deque holding indices in decreasing order of value
- BA singly linked list of the window's elements
- CA sorted array updated by shifting
- DA min-heap rebuilt for every window
8.Hard
For each element of an array you want the next greater element to its right, in O(n) total time. Which structure helps?
- AA queue that holds every pair of elements
- BA binary search tree rebuilt for each element
- CA hash table of all elements
- DA stack that keeps elements waiting for their answer
Answer key
- 1. D · The number of edges from the root to that node
- 2. B · At the root
- 3. B · In one contiguous block, one after another
- 4. A · Follow left children from the root until there is no left child
- 5. C · 2i + 1 and 2i + 2
- 6. A · Ascending sorted order
- 7. A · A deque holding indices in decreasing order of value
- 8. D · A stack that keeps elements waiting for their answer
Full step-by-step solutions: practise this topic on examproblems.com.