Binary Tree · Data Structures
35 questions · asked in 17 of 27 years (2000–2026)
MCQ 27 · NAT 81-mark 26 · 2-mark 9
2000Questions per year2026
Questions 21–25 of 35
The inorder and preorder traversal of a binary tree are d b e a f c g and a b d e c f g, respectively The postorder traversal of the binary tree is:
Answer: (A)
The first node in the preorder traversal is the root, so a is the root of the tree.
In the inorder traversal, every node on the left of is in the left subtree of . Every node on the right is in the right subtree of .
The second node in the preorder traversal is . It goes to the left subtree of , because it lies on the left of in the inorder list.
We continue in the same way and build the binary tree:
Postorder visits the left subtree, then the right subtree, then the root. Left subtree of : d e b. Right subtree of : f g c. Then the root a. So the postorder traversal is d e b f g c a.
Answer: (A)
In the inorder traversal, every node on the left of is in the left subtree of . Every node on the right is in the right subtree of .
The second node in the preorder traversal is . It goes to the left subtree of , because it lies on the left of in the inorder list.
We continue in the same way and build the binary tree:
Postorder visits the left subtree, then the right subtree, then the root. Left subtree of : d e b. Right subtree of : f g c. Then the root a. So the postorder traversal is d e b f g c a.
Answer: (A)
The maximum number of binary trees that can be formed with three unlabeled nodes is:
Answer: (B)
The number of binary trees with unlabeled nodes is the Catalan number .
For : .
Check by counting: with the root taken out, the other 2 nodes go as (0 left, 2 right), (1 left, 1 right) or (2 left, 0 right). These give 2, 1 and 2 trees, so 2 + 1 + 2 = 5.
Note also that the number of binary search trees on distinct keys is the same Catalan number, equal to the number of unlabeled binary trees.
Answer: (B)
For : .
Check by counting: with the root taken out, the other 2 nodes go as (0 left, 2 right), (1 left, 1 right) or (2 left, 0 right). These give 2, 1 and 2 trees, so 2 + 1 + 2 = 5.
Note also that the number of binary search trees on distinct keys is the same Catalan number, equal to the number of unlabeled binary trees.
Answer: (B)
The height of a binary tree is the maximum number of edges in any root to leaf path. The maximum number of nodes in a binary tree of height h is:
Answer: (C)
Height is counted in edges, so a tree of height has levels 0 to . Level holds at most nodes. So the most nodes are
Test it on small trees. For there is just the root, 1 node, and . For the root has two children, 3 nodes, and . The other options fail at : (A) gives 0, (B) gives and (D) gives 2.
Answer: (C)
Test it on small trees. For there is just the root, 1 node, and . For the root has two children, 3 nodes, and . The other options fail at : (A) gives 0, (B) gives and (D) gives 2.
Answer: (C)
An array X of n distinct integers is interpreted as a complete binary tree. The index of the first element of the array is 0. If the root node is at level 0, the level of element , is
Answer: (C)
Note: the value written inside each node is the array index.
With the root at index 0, level holds the indices to . So for an element at level , , which gives . So (C) is correct.
The others fail on small cases:
(A) For , , but lies at level 1.
(B) For , , but lies at level 2.
(D) For , , but lies at level 1.
Answer: (C)
An array X of n distinct integers is interpreted as a complete binary tree. The index of the first element of the array is 0. If only the root node does not satisfy the heap property, the algorithm to convert the complete binary tree into a heap has the best asymptotic time complexity of
Answer: (B)
We call the Heapify / Bubble down / Percolate down procedure on the root. In the worst case, it takes time So the correct option is .
The other options make no sense. With time we can build a whole heap, not just heapify the root. is larger than .
The other options make no sense. With time we can build a whole heap, not just heapify the root. is larger than .
Keep practising