1.Easy
The depth of a node in a tree is:
- AThe number of nodes in its subtree
- BThe number of children of that node
- CThe number of edges from the root to that node
- DThe number of edges from that node to the deepest leaf
2.Easy
Which data structure works on the principle "last in, first out"?
- AQueue
- BLinked list
- CHash table
- DStack
3.Easy
In which order does a postorder traversal of a binary tree visit nodes?
- ALeft subtree, then node, then right subtree
- BLeft subtree, then right subtree, then node
- CRight subtree, then node, then left subtree
- DNode, then left subtree, then right subtree
4.Medium
A binary tree has root 1 with left child 2 and right child 3; node 2 has children 4 (left) and 5 (right). What is the preorder traversal?
- A1 2 4 5 3
- B1 2 3 4 5
- C4 2 5 1 3
- D4 5 2 3 1
5.Medium
Why can a binary heap be stored in an array without any pointers?
- AHeaps never contain more than 100 elements
- BArrays automatically keep the keys in sorted order, so no pointers are needed
- CIt is a complete binary tree, so positions follow simple index formulas
- DAll keys in a heap are equal
6.Medium
An adjacency matrix for a graph with V vertices uses how much memory?
- AO(V²)
- BO(E)
- CO(V + E)
- DO(log V)
7.Hard
A Bloom filter can answer "is this element in the set?" with:
- APossible false positives but no false negatives
- BAnswers only for numbers
- CPossible false negatives but no false positives
- DExact answers always
8.Hard
Why are B-trees used in databases and file systems?
- ATheir high branching factor keeps the tree shallow, reducing slow disk reads
- BThey use less memory than any array, so the entire index always fits in main memory
- CThey need no rebalancing
- DThey store data unsorted
Answer key
- 1. C · The number of edges from the root to that node
- 2. D · Stack
- 3. B · Left subtree, then right subtree, then node
- 4. A · 1 2 4 5 3
- 5. C · It is a complete binary tree, so positions follow simple index formulas
- 6. A · O(V²)
- 7. A · Possible false positives but no false negatives
- 8. A · Their high branching factor keeps the tree shallow, reducing slow disk reads
Full step-by-step solutions: practise this topic on examproblems.com.