Multiple choice

Given a sequence of numbers 8, 4, 9, 3, 2, 0, 11, 10 to be inserted in the tree. Which key will be visited last in the inorder traversal of the inserted keys?

Here is an algorithm to insert a key k in a binary search tree T.
insert(T,k)
{
int flag = 0;
node x = root[T];
if(x == null)
{
root = new node(k);
}
while(x != null)
{
if(x > k)
{
Y = x;
X = left[x];
flag = 1;
}
else
{
Y = x;
X = right[x];
flag = 2;
}
}
if(flag ==1)
{
K = left[y];
}
else
{
K = right[y];
}
}

  1. 10

  2. 9

  3. 11

  4. 8

  5. 4

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

This is correct. since with insertion and inorder traversal the rightmost key will be referred last. During insertion since 11 comes second last and only 10 comes after that which will be the left key of 11 so inorder traversal will visit 11 key only at the end.