1.Easy
Which data structure is most suitable for the "undo" feature in a text editor?
- AGraph
- BQueue
- CStack
- DHash set
2.Easy
The height of a tree is commonly defined as:
- AThe number of edges on the longest path from the root to a leaf
- BThe number of children of the root
- CThe total number of nodes in the tree, counting the root and every leaf
- DThe number of leaves in the tree
3.Easy
What is the defining feature of a set as an abstract data type?
- AIt stores elements in sorted order
- BIt allows access only at one end
- CIt stores elements without duplicates
- DIt stores key-value pairs
4.Medium
How do you find the minimum key in a binary search tree?
- ALook at the root only
- BFollow left children from the root until there is no left child
- CVisit every leaf and compare them
- DFollow right children from the root until there is no right child
5.Medium
A node in a binary search tree has a right subtree. Where is its in-order successor?
- AThe leftmost node of its right subtree
- BIts parent, always
- CThe rightmost node of its left subtree
- DIts right child, always
6.Medium
What is the worst-case height of a binary search tree with n nodes if keys are inserted in sorted order?
- A1
- Bn (it becomes a linked list)
- Clog₂ n
- D√n
7.Hard
A segment tree is typically used to:
- AImplement a stack
- BSort strings alphabetically by storing each prefix in a separate tree node
- CAnswer range queries (such as range sums) and updates in O(log n)
- DStore a graph's edges
8.Hard
In Kruskal's minimum spanning tree algorithm, what is the union-find structure used for?
- AChecking whether an edge's two endpoints are already connected
- BChoosing the starting vertex
- CSorting the edges by weight
- DStoring each vertex's current distance from the source during the search
Answer key
- 1. C · Stack
- 2. A · The number of edges on the longest path from the root to a leaf
- 3. C · It stores elements without duplicates
- 4. B · Follow left children from the root until there is no left child
- 5. A · The leftmost node of its right subtree
- 6. B · n (it becomes a linked list)
- 7. C · Answer range queries (such as range sums) and updates in O(log n)
- 8. A · Checking whether an edge's two endpoints are already connected
Full step-by-step solutions: practise this topic on examproblems.com.