• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Top MCQs on Binary Search Tree (BST) Data Structure with Answers

Question 11

Consider the same code as given in above question. What does the function print() do in general? The function print() receives root of a Binary Search Tree (BST) and a positive integer k as arguments.
C
// A BST node
struct node {
    int data;
    struct node *left, *right;
};

int count = 0;

void print(struct node *root, int k)
{
    if (root != NULL && count <= k)
    {
        print(root->right, k);
        count++;
        if (count == k)
          printf(\"%d \", root->data);
       print(root->left, k);
    }
}
  • Prints the kth smallest element in BST
  • Prints the kth largest element in BST
  • Prints the leftmost node at level k from root
  • Prints the rightmost node at level k from root

Question 12

You are given the postorder traversal, P, of a binary search tree on the n elements 1, 2, ..., n. You have to determine the unique binary search tree that has P as its postorder traversal. What is the time complexity of the most efficient algorithm for doing this?

  • O(Logn)

  • O(n)

  • O(nLogn)

  • none of the above, as the tree cannot be uniquely determined.

Question 13

Suppose we have a balanced binary search tree T holding n numbers. We are given two numbers L and H and wish to sum up all the numbers in T that lie between L and H. Suppose there are m such numbers in T. If the tightest upper bound on the time to compute the sum is O(nalogb n + mc logd n), the value of a + 10b + 100c + 1000d is ____.
  • 60
  • 110
  • 210
  • 50

Question 14

Let T(n) be the number of different binary search trees on n distinct elements. Then GATECS2003Q7, where x is
  • n-k+1
  • n-k
  • n-k-1
  • n-k-2

Question 15

What are the worst-case complexities of insertion and deletion of a key in a binary search tree?
  • Θ(logn) for both insertion and deletion
  • Θ(n) for both insertion and deletion
  • Θ(n) for insertion and Θ(logn) for deletion
  • Θ(logn) for insertion and Θ(n) for deletion

Question 16

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
  • 65
  • 67
  • 69
  • 83

Question 17

The number of ways in which the numbers 1, 2, 3, 4, 5, 6, 7 can be inserted in an empty binary search tree, such that the resulting tree has height 6, is _____________ Note: The height of a tree with a single node is 0. [This question was originally a Fill-in-the-Blanks question]
  • 2
  • 4
  • 64
  • 32

Question 18

Suppose that we have numbers between 1 and 100 in a binary search tree and want to search for the number 55. Which of the following sequences CANNOT be the sequence of nodes examined?
  • {10, 75, 64, 43, 60, 57, 55}
  • {90, 12, 68, 34, 62, 45, 55}
  • {9, 85, 47, 68, 43, 57, 55}
  • {79, 14, 72, 56, 16, 53, 55}

Question 19

A Binary Search Tree (BST) stores values in the range 37 to 573. Consider the following sequence of keys.

I. 81, 537, 102, 439, 285, 376, 305
II. 52, 97, 121, 195, 242, 381, 472
III. 142, 248, 520, 386, 345, 270, 307
IV. 550, 149, 507, 395, 463, 402, 270

Suppose the BST has been unsuccessfully searched for key 273. Which all of the above sequences list nodes in the order in which we could have encountered them in the search?
  • II and III only
  • I and III only
  • III and IV only
  • III only

Question 20

A Binary Search Tree (BST) stores values in the range 37 to 573. Consider the following sequence of keys.
I. 81, 537, 102, 439, 285, 376, 305
II. 52, 97, 121, 195, 242, 381, 472
III. 142, 248, 520, 386, 345, 270, 307
IV. 550, 149, 507, 395, 463, 402, 270
Which of the following statements is TRUE?
  • I, II and IV are inorder sequences of three different BSTs
  • I is a preorder sequence of some BST with 439 as the root
  • II is an inorder sequence of some BST where 121 is the root and 52 is a leaf
  • IV is a postorder sequence of some BST with 149 as the root

There are 41 questions to complete.

Last Updated :
Take a part in the ongoing discussion