• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Top 50 Data Structures MCQs with Answers

Question 21

Suppose the numbers 7, 5, 1, 8, 3, 6, 0, 9, 4, 2 are inserted in that order into an initially empty binary search tree. The binary search tree uses the usual ordering on natural numbers. What is the in-order traversal sequence of the resultant tree?
  • 7 5 1 0 3 2 4 6 8 9
  • 0 2 4 3 1 6 5 9 8 7
  • 0 1 2 3 4 5 6 7 8 9
  • 9 8 6 4 2 3 0 1 5 7

Question 22

The average depth of a binary search tree is:
  • O(n0.5)
  • O(n)
  • O(log n)
  • O(n log n)

Question 23

When searching for the key value 60 in a binary search tree, nodes containing the key values 10, 20, 40, 50, 70 80, 90 are traversed, not necessarily in the order given. How many different orders are possible in which these key values can occur on the search path from the root to the node containing the value 60?
  • 35
  • 64
  • 128
  • 5040

Question 24

The following numbers are inserted into an empty binary search tree in the given order: 10, 1, 3, 5, 15, 12, 16. What is the height of the binary search tree (the height is the maximum distance of a leaf node from the root)?
  • 2
  • 3
  • 4
  • 6

Question 25

The postorder traversal of a binary tree is 8, 9, 6, 7, 4, 5, 2, 3, 1. The inorder traversal of the same tree is 8, 6, 9, 4, 7, 2, 5, 1, 3. The height of a tree is the length of the longest path from the root to any leaf. The height of the binary tree above is ________ . Note -This was Numerical Type question.
  • 2
  • 3
  • 4
  • 5

Question 26

What is the worst case time complexity of inserting n2 elements into an AVL-tree with n elements initially ?
  • Θ(n4)
  • Θ(n2)
  • Θ(n2 log n)
  • Θ(n3)

Question 27

Which of the following is TRUE?

  • The cost of searching an AVL tree is θ (log n) but that of a binary search tree is O(n)

  • The cost of searching an AVL tree is θ (log n) but that of a complete binary tree is θ (n log n)

  • The cost of searching a binary search tree is O (log n ) but that of an AVL tree is θ(n)

  • The cost of searching an AVL tree is θ (n log n) but that of a binary search tree is O(n)

Question 28

Which of the following is AVL Tree?
A
        100
     /      \\
    50       200
   /           \\
 10            300


B
           100
       /       \\
     50        200
    /        /     \\
  10       150     300
 /
5


C
            100
       /          \\
     50            200
    /  \\          /     \\
  10    60       150     300
 /                 \\        \\
5                   180       400

  • Only A
  • A and C
  • A, B and C
  • Only B

Question 29

Consider the following left-rotate and right-rotate functions commonly used in self-adjusting BSTs
T1, T2 and T3 are subtrees of the tree rooted with y (on left side) 
or x (on right side)           
                y                               x
               / \\     Right Rotation          /  \\
              x   T3   – - – - – - – >        T1   y 
             / \\       < - - - - - - -            / \\
            T1  T2     Left Rotation            T2  T3

Which of the following is tightest upper bound for left-rotate and right-rotate operations.
  • O(1)
  • O(Logn)
  • O(LogLogn)
  • O(n)

Question 30

What is the worst case possible height of AVL tree?

  • 2Logn (Assume base of log is 2)

  • 1.44log n (Assume base of log is 2)

  • Depends upon implementation

  • Theta(n)

There are 50 questions to complete.

Last Updated :
Take a part in the ongoing discussion