1.Easy
The depth of a node in a tree is:
- AThe number of nodes in its subtree
- BThe number of edges from that node to the deepest leaf
- CThe number of children of that node
- DThe number of edges from the root to that node
2.Easy
In a binary search tree, values in the left subtree of a node are:
- ASmaller than the node's value
- BLarger than the node's value
- CEqual to the node's value
- DIn random order
3.Easy
A graph consists of:
- AVertices (nodes) connected by edges
- BKeys and hashes only
- CRows and columns
- DOnly a root and leaves
4.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(log n)
- BO(n²)
- CO(1)
- DO(n)
5.Medium
What is the cost of inserting an element in the middle of an array of n elements?
- AO(n²), because each element moves n times
- BO(log n), because of binary search
- CO(1), because the index is known
- DO(n), because later elements must shift
6.Medium
An adjacency matrix for a graph with V vertices uses how much memory?
- AO(log V)
- BO(V + E)
- CO(E)
- DO(V²)
7.Hard
Why do databases often use B+ trees rather than plain B-trees for indexes?
- AB+ trees use binary internal nodes, which reduces the number of disk reads
- BAll records are in linked leaves, which makes range scans efficient
- CB+ trees store data only in the root
- DB+ trees do not need to be balanced
8.Hard
The keys 5, 3, 8, 1 are inserted in this order into an empty array-based binary min-heap. What is the final array?
- A[1, 3, 8, 5]
- B[3, 1, 8, 5]
- C[1, 5, 8, 3]
- D[1, 3, 5, 8]
Answer key
- 1. D · The number of edges from the root to that node
- 2. A · Smaller than the node's value
- 3. A · Vertices (nodes) connected by edges
- 4. C · O(1)
- 5. D · O(n), because later elements must shift
- 6. D · O(V²)
- 7. B · All records are in linked leaves, which makes range scans efficient
- 8. A · [1, 3, 8, 5]
Full step-by-step solutions: practise this topic on examproblems.com.