1.Easy
What is a deque (double-ended queue)?
- AA structure that allows insertion and removal at both ends
- BA queue sorted by priority
- CA queue that only allows removal at the back
- DTwo separate queues sharing one array
2.Easy
In a tree, what are sibling nodes?
- AA node and its parent
- BNodes at the same depth in different subtrees
- CNodes that have no children
- DNodes that share the same parent
3.Easy
The height of a tree is commonly defined as:
- AThe total number of nodes in the tree, counting the root and every leaf
- BThe number of children of the root
- CThe number of leaves in the tree
- DThe number of edges on the longest path from the root to a leaf
4.Medium
Which data structure is used to check whether the brackets in "{[()]}" are balanced?
- AA queue
- BA binary search tree
- CA hash table
- DA stack
5.Medium
Which abstract data type does Dijkstra's algorithm use to choose the next vertex to process?
- AA set with no ordering
- BA min-priority queue
- CA FIFO queue
- DA stack
6.Medium
Which data structure is used by depth-first search (iterative version)?
- AA stack
- BA heap
- CA hash table only
- DA queue
7.Hard
A dynamic array doubles when full. Why do many implementations shrink it only when it is one quarter full, not half full?
- ATo avoid repeated resizing when pushes and pops alternate near the boundary
- BBecause halving at one half would lose elements
- CTo keep the array sorted
- DBecause the memory allocator can only release memory in quarters of a block
8.Hard
Without union by rank or path compression, what is the worst-case cost of a single find in a union-find structure with n elements?
- AO(1)
- BO(α(n))
- CO(n)
- DO(log n)
Answer key
- 1. A · A structure that allows insertion and removal at both ends
- 2. D · Nodes that share the same parent
- 3. D · The number of edges on the longest path from the root to a leaf
- 4. D · A stack
- 5. B · A min-priority queue
- 6. A · A stack
- 7. A · To avoid repeated resizing when pushes and pops alternate near the boundary
- 8. C · O(n)
Full step-by-step solutions: practise this topic on examproblems.com.