GATE | GATE-CS-2015 (Set 3) | Question 23

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

(A) 65
(B) 67
(C) 69
(D) 83


Answer: (B)

Explanation: Here is The Insertion Algorithm For a Binary Search Tree :

Insert(Root,key)
{
    if(Root is NULL)
        Create a Node with value as key and return
    Else if(Root.key >= key)
        Insert(Root.left,key)
    Else
        Insert(Root.right,key)
}

Creating the BST one by one using the above algorithm in the below given image :

pranjul_23

This solution is contributed by Pranjul Ahuja.


Quiz of this Question

My Personal Notes arrow_drop_up

Improved By : Parmod Jangra