1.Easy
In which order does a preorder traversal of a binary tree visit nodes?
- ALevel by level from the top
- BLeft subtree, then node, then right subtree
- CLeft subtree, then right subtree, then node
- DNode, then left subtree, then right subtree
2.Easy
What is the max-heap property?
- AEvery parent's key is greater than or equal to its children's keys
- BThe keys are sorted from left to right
- CAll leaves contain the maximum key
- DEvery left child's key is greater than or equal to its right sibling's key
3.Easy
A hash table stores data as:
- AKey–value pairs located by a hash function
- BA tree with ordered keys
- CA sorted list only
- DA fixed-length string
4.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 preorder traversal?
- A1 2 3 4 5
- B4 5 2 3 1
- C4 2 5 1 3
- D1 2 4 5 3
5.Medium
A trie (prefix tree) is especially efficient for:
- APrefix searches such as autocomplete
- BFinding shortest paths
- CStoring matrices
- DSorting numbers
6.Medium
An in-order traversal of a binary search tree visits the keys in:
- AAscending sorted order
- BLevel order
- CInsertion order
- DDescending order always
7.Hard
The time complexity of decrease-key in a binary heap (given the element's position) is:
- AO(1)
- BO(log n)
- CO(n)
- DO(n log n)
8.Hard
Which structure lets you compute the maximum of every window of size k in an array in O(n) total?
- AA sorted array updated by shifting
- BA singly linked list of the window's elements
- CA min-heap rebuilt for every window
- DA deque holding indices in decreasing order of value
Answer key
- 1. D · Node, then left subtree, then right subtree
- 2. A · Every parent's key is greater than or equal to its children's keys
- 3. A · Key–value pairs located by a hash function
- 4. D · 1 2 4 5 3
- 5. A · Prefix searches such as autocomplete
- 6. A · Ascending sorted order
- 7. B · O(log n)
- 8. D · A deque holding indices in decreasing order of value
Full step-by-step solutions: practise this topic on examproblems.com.