Topic: tree edges/height · BST insert/search/delete · M-way search trees · traversals · complete binary trees · array representation
Questions: 20 MCQ (full options)
Source: class WhatsApp group (Chats/WhatsApp-Cheat-code/chat.md), set "DAA Assignment 3" (2 Nov 2026).
Verification: ✅ all 20 re-derived — all correct. Q8 is the one to watch: the "inorder successor" wording is tested against a concrete tree.
Quick answer key
| Q | Ans | Q | Ans | Q | Ans | Q | Ans |
|---|---|---|---|---|---|---|---|
| 1 | b | 6 | c | 11 | c | 16 | c |
| 2 | d | 7 | b | 12 | d | 17 | c |
| 3 | d | 8 | d | 13 | d | 18 | b |
| 4 | a | 9 | b | 14 | d | 19 | a |
| 5 | d | 10 | c | 15 | a | 20 | d |
Q1. A tree containing n nodes has how many edges?
a. 2n b. n−1 c. n d. n+1
✅ b — n−1. A tree is connected and acyclic; every node except the root has exactly one incoming edge.
Q2. Which statement about a complete binary tree is correct?
a. Its last level is filled right to left b. Every node has either zero or two children c. All leaves at the same depth d. It can be efficiently represented using an array
✅ d — array representation. Level order maps directly to consecutive array indices, so child/parent links are index arithmetic. Related: (b) describes a full/proper tree; (c) describes a perfect tree; a complete tree only requires that all levels except possibly the last are full and the last is filled left to right.
Q3. Insert 40, 20, 60, 10, 30 into an empty BST. What is the root?
a. 10 b. 20 c. 60 d. 40
✅ d — 40. The first inserted key becomes the root; all later keys are placed by comparison.
Q4. Worst-case search time in a BST of n nodes?
a. O(n) b. O(1) c. O(log n) d. O(n log n)
✅ a — O(n). An unbalanced tree degenerates to a chain. Related: O(log n) is the balanced-tree (AVL/red-black) guarantee, not the BST guarantee.
Q5. Insert 10, 20, 30, 40 into an empty BST. Resulting structure?
a. Balanced BST b. Left-skewed c. Complete binary tree d. Right-skewed
✅ d — right-skewed. Each new key is larger than all previous ones, so it always goes to the right child of the previous node. This is exactly Q4's worst case.
Q6. Inorder traversal of a BST containing 25, 15, 35, 10, 20 (inserted in that order)?
a. 10, 20, 15, 35, 25 b. 35, 25, 20, 15, 10 c. 10, 15, 20, 25, 35 d. 25, 15, 10, 20, 35
✅ c — 10, 15, 20, 25, 35. Inorder of any BST yields sorted order; that alone picks c. Related: (b) is reverse-inorder (descending), (d) is preorder.
Q7. Deleting a BST node with exactly one child — the node is typically:
a. Always replaced by its inorder successor b. Replaced by its child, linking that child to the deleted node's parent c. Replaced by the root d. Left unchanged
✅ b. With one child, splice the child into the parent — the BST invariant is preserved. Related: the successor/predecessor replacement is needed only for a node with two children.
Q8. Root 50, left child 30, right child 70; 70 has children 60 and 80. Delete 70 using its inorder successor — which key replaces it?
a. 50 b. 60 c. 30 d. 80
✅ d — 80. Inorder successor = leftmost node of the right subtree of 70 = 80 (60 is the left child of 70, i.e. it precedes 70 in inorder). Careful: the common mistake is to answer 60 by reading "successor" as "left child". Inorder of this tree's right side is 60, 70, 80 — so 80 is the successor.
Q9. In a standard M-way search tree, a node can contain at most how many keys?
a. M b. M−1 c. 2M d. M+1
✅ b — M−1. M children are separated by at most M−1 keys (M pointers → M−1 separators).
Q10. In a 4-way search tree, the maximum number of keys in one node?
a. 5 b. 4 c. 3 d. 2
✅ c — 3 = M−1 = 4−1.
Q11. Insertion of a new key into a standard M-way search tree generally begins by:
a. Deleting the smallest key b. Sorting all keys and rebuilding c. Searching for the appropriate position according to key ranges d. Replacing the root immediately
✅ c. Descend using the key ranges stored in each node until you reach the target leaf.
Q12. The number of edges on the longest path from the root to a leaf is called the:
a. Level of the root b. Width of the tree c. Degree of the tree d. Height of the tree
✅ d — height. Related: if height is counted in nodes instead of edges, the same tree has height h+1 — always check the convention (Q14 and Q19 depend on it).
Q13. Which statement about deletion in a general M-way search tree is correct?
a. Every deletion requires converting the tree into a BST b. Every deletion always removes a leaf c. Deletion is impossible if a node has multiple keys d. Deletion may require replacing an internal key with a predecessor or successor and repairing the affected subtree
✅ d.
Q14. A binary tree has 12 nodes. Minimum possible height in edges?
a. 2 b. 4 c. 5 d. 3
✅ d — 3. A perfect tree of height 3 holds 2⁴−1 = 15 ≥ 12 nodes, while height 2 holds only 7 < 12. Related: the minimum height is ⌈log₂(n+1)⌉ − 1.
Q15. Which traversal visits nodes in the order Root–Left–Right?
a. Preorder b. Level order c. Inorder d. Postorder
✅ a — preorder. Inorder = L–Root–R; postorder = L–R–Root; level order = BFS by depth.
Q16. Which traversal of a BST produces keys in ascending order (distinct keys)?
a. Postorder b. Preorder c. Inorder d. First order
✅ c — inorder.
Q17. Tree: A root, B left child of A, C right child of A, D and E children of B. Preorder?
a. D, B, E, A, C b. D, E, B, C, A c. A, B, D, E, C d. A, C, B, E, D
✅ c — A, B, D, E, C. Root, then the whole left subtree (B, D, E), then the right subtree (C). Related: (a) is inorder, (b) is postorder — the three traversals of the same tree.
Q18. A complete binary tree is one in which:
a. Every level must be completely filled b. All levels except possibly the last are full, and the last is filled left to right c. Every leaf at the same level d. Every node has exactly two children
✅ b — the definition. (a)+(c) describe a perfect tree; (d) a full/proper tree.
Q19. Maximum number of nodes in a binary tree of height h (height in edges)?
a. 2^(h+1) − 1 b. 2^h c. h² + 1 d. 2^(h+1)
✅ a — 2^(h+1) − 1. Levels 0..h each hold 2^level nodes; the geometric sum is 2^(h+1)−1. Check h=0 (single node): 2¹−1 = 1. ✓
Q20. In a complete binary tree stored in a zero-indexed array, the left child of the node at index i is at:
a. 2i b. 2i+2 c. i+1 d. 2i+1
✅ d — 2i+1. Zero-indexed: parent = ⌊(i−1)/2⌋, left = 2i+1, right = 2i+2. Related: with a one-indexed array the classical formulas are left = 2i and right = 2i+1 — mixing the two indexing conventions is the classic off-by-one in this question.