GATE 2005
203 questions
MCQ 2031-mark 203
Questions 101–105 of 203
Answer: (A)
Correct Answer:
Answer: (B)
For : one subtree of the root has height , so it has at least nodes, say . The other subtree has at least nodes. So .
Then , and starting from this gives .
This is reached: take a full binary tree with levels 0 to ( nodes) and hang two nodes, one below the other, under one leaf. That leaf has 2 nodes on one side and 0 on the other, and each ancestor has a difference of exactly 2, so the rule holds. The tree has nodes and height .
Answer: (B)
Answer: (C)
Make one leaf an internal node by giving it children. That leaf is lost and new leaves appear, so the number of leaves goes up by . The number of internal nodes goes up by .
Every complete -ary tree with internal nodes is built by such steps, so
leaves .
Check with : one root with children has leaves, and the formula gives . Option (B) gives here and option (D) gives , so both are wrong.
Answer: (C)
Answer: (D)
Build the tree from the preorder 5, 3, 1, 2, 4, 6, 8, 7. The first key, 5, is the root. Each next key is placed with the BST rule:
3 is less than 5: left child of 5. 1 is less than 5 and 3: left child of 3. 2 is less than 5 and 3 but more than 1: right child of 1. 4 is less than 5 but more than 3: right child of 3. 6 is more than 5: right child of 5. 8 is more than 5 and 6: right child of 6. 7 is more than 5 and 6 but less than 8: left child of 8. This gives the tree in the figure.
Postorder is left subtree, right subtree, root.
Left subtree of 5 (root 3): the subtree of 1 gives 2, 1, then 4, then 3, so 2, 1, 4, 3.
Right subtree of 5 (root 6): the subtree of 8 gives 7, 8, then 6, so 7, 8, 6.
Then the root 5. The postorder is 2, 1, 4, 3, 7, 8, 6, 5.
Answer: (D)
Answer: (C)
The first number inserted becomes the root of the tree. Call it .
Every number larger than goes into the right sub-tree (RST), and every number smaller than goes into the left sub-tree (LST). Among , exactly numbers are larger than . The RST has nodes, so , that is .
So the numbers split like this:
LST: (that is numbers)
Root: (1 number)
RST: ( numbers)
Check: if , every other number is smaller, so the root must be , which is . Option (A), , would give 0 here.
Answer: (C)