1.Easy
Which structure is typically used to implement a priority queue?
- AA stack
- BA heap
- CA singly linked list without order
- DA string
2.Easy
What is a directed graph?
- AA graph whose edges all have weights
- BA graph whose edges have a direction from one vertex to another
- CA graph that has no cycles
- DA graph in which every pair of distinct vertices is joined by an edge
3.Easy
What is the root of a tree?
- AThe top node with no parent
- BAny node in the middle
- CA node with no children
- DThe node with the largest value
4.Medium
In a circular queue stored in an array of capacity n, how is the next position after index i computed?
- Ai + 1
- B(i + 1) mod n
- C(i − 1) mod n
- D2i + 1
5.Medium
A queue is implemented with two stacks: push onto an "in" stack, and pop from an "out" stack, refilling it from "in" when empty. What is the amortised cost per operation?
- AO(n)
- BO(log n)
- CO(1)
- DO(n²)
6.Medium
In a binary heap stored in an array starting at index 0, where is the parent of the node at index i?
- AAt index i − 1
- BAt index ⌊i / 2⌋ + 1
- CAt index ⌊(i − 1) / 2⌋
- DAt index 2i + 1
7.Hard
Which statement about heapsort is correct?
- AIt is stable and needs O(n) extra memory
- BIt sorts in place in O(n log n) worst-case time but is not stable
- CIt runs in O(n) time on any input
- DIt needs a binary search tree as extra storage, so it uses O(n) extra memory
8.Hard
A Fenwick tree (binary indexed tree) over an array of n numbers supports which operations in O(log n)?
- AInserting elements at any position
- BSorting the array and binary search
- CFinding the median in O(1)
- DPrefix-sum queries and single-element updates
Answer key
- 1. B · A heap
- 2. B · A graph whose edges have a direction from one vertex to another
- 3. A · The top node with no parent
- 4. B · (i + 1) mod n
- 5. C · O(1)
- 6. C · At index ⌊(i − 1) / 2⌋
- 7. B · It sorts in place in O(n log n) worst-case time but is not stable
- 8. D · Prefix-sum queries and single-element updates
Full step-by-step solutions: practise this topic on examproblems.com.