1.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 in which every pair of distinct vertices is joined by an edge
- DA graph that has no cycles
2.Easy
What is the name of the stack operation that adds an element to the top?
- APop
- BPush
- CPeek
- DEnqueue
3.Easy
Which data structure works on the principle "first in, first out"?
- AQueue
- BBinary tree
- CStack
- DHeap
4.Medium
How is a new element inserted into a binary heap?
- ARebuild the whole heap from scratch
- BPlace it at the end of the array and sift it up while it violates the heap property
- CInsert it at its sorted position by shifting all of the larger elements one place right
- DPlace it at the root and sift it down
5.Medium
What is the time complexity of searching for a key in a balanced binary search tree?
- AO(n)
- BO(log n)
- CO(n log n)
- DO(1)
6.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/2 and i/2 + 1
- Bi + 1 and i + 2
- C2i and 2i + 1
- D2i + 1 and 2i + 2
7.Hard
The time complexity of decrease-key in a binary heap (given the element's position) is:
- AO(log n)
- BO(1)
- CO(n)
- DO(n log n)
8.Hard
Why do databases often use B+ trees rather than plain B-trees for indexes?
- AAll records are in linked leaves, which makes range scans efficient
- BB+ trees do not need to be balanced
- CB+ trees use binary internal nodes, which reduces the number of disk reads
- DB+ trees store data only in the root
Answer key
- 1. B · A graph whose edges have a direction from one vertex to another
- 2. B · Push
- 3. A · Queue
- 4. B · Place it at the end of the array and sift it up while it violates the heap property
- 5. B · O(log n)
- 6. D · 2i + 1 and 2i + 2
- 7. A · O(log n)
- 8. A · All records are in linked leaves, which makes range scans efficient
Full step-by-step solutions: practise this topic on examproblems.com.