Question
While inserting the elements 71, 65, 84, 69, 67, 83 in an empty binary search tree (BST) in the sequence shown, the element in the lowest level is
Official answer and solution
- Official answer
- B
- From
- Official GATE 2015 answer key
Solution
Trace the step-by-step insertion of keys into a Binary Search Tree and record the depth of each node.
Insert the elements 71, 65, 84, 69, 67, 83 into an initially empty BST:
- Insert 71: Root node at Level 0.
- Insert 65: , placed as the left child of 71 (Level 1).
- Insert 84: , placed as the right child of 71 (Level 1).
- Insert 69: (left), (right), placed as the right child of 65 (Level 2).
- Insert 67: (left), (right), (left), placed as the left child of 69 (Level 3).
- Insert 83: (right), (left), placed as the left child of 84 (Level 2).
The levels of the nodes are:
- Level 0: 71
- Level 1: 65, 84
- Level 2: 69, 83
- Level 3: 67
The element at the lowest level (greatest depth) is 67 at Level 3 (Option B).
B
Assuming the lowest level corresponds to the minimum numeric value (65) rather than the node with the maximum tree depth.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2015 Computer Science and Information Technology (CS) Session 3
- Question
- 23 of 65, printed as CS Q.13
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.