Commerce

Binary Search TreesB Tree MCQs

Practice Binary Search TreesB Tree MCQs for competitive exams.

Binary Search TreesB Tree MCQs

Practice questions from this topic.

What is the disadvantage of using splay trees?

  1. A. height of a splay tree can be linear when accessing elements in non decreasing order.
  2. B. splay operations are difficult
  3. C. no significant disadvantage
  4. D. splay tree performs unnecessary splay when a node is only being read
Report Error

When it would be optimal to prefer Red-black trees over AVL trees?

  1. A. when there are more insertions or deletions
  2. B. when more search is needed
  3. C. when tree must be balanced
  4. D. when log(nodes) time complexity is needed
Report Error

For the tree below, write the level-order traversal.

  1. A. 2, 7, 2, 6, 5, 11, 5, 9, 4
  2. B. 2, 7, 5, 2, 11, 9, 6, 5, 4
  3. C. 2, 5, 11, 6, 7, 4, 9, 5, 2
  4. D. 2, 7, 5, 6, 11, 2, 5, 4, 9
Report Error

Why we need to a binary tree which is height balanced?

  1. A. to avoid formation of skew trees
  2. B. to save memory
  3. C. to attain faster memory access
  4. D. to simplify storing
Report Error

What is the space complexity of a treap algorithm?

  1. A. O(N)
  2. B. O(log N)
  3. C. O(N log N)
  4. D. O(N 2 )
Report Error

Is it true that splay trees have O(logn) amortized complexity ?

  1. A. true
  2. B. false
Report Error

Can a tree stored in an array using either one of inorder or post order or pre order traversals be again reformed?

  1. A. Yes just traverse through the array and form the tree
  2. B. No we need one more traversal to form a tree
  3. C. No in case of sparse trees
  4. D. Yes by using both inorder and array elements
Report Error

Why the below pseudo code where x is a value, wt is weight factor and t is root node can't insert? WeightBalanceTreeNode insert(int x, int wt, WeightBalanceTreeNode k) : if (k == null) k = new WeightBalanceTreeNode(x, wt, null, null) else if (x < t.element) : k.left = insert (x, wt, k.left) if (k.left.weight t.element) : k.right = insert (x, wt, k.right) if (k.right.weight < k.weight) k = rotateWithLeftChild (k)

  1. A. when x>t. element Rotate-with-left-child should take place and vice versa
  2. B. the logic is incorrect
  3. C. the condition for rotating children is wrong
  4. D. insertion cannot be performed in weight balanced trees
Report Error

In a full binary tree if there are L leaves, then total number of nodes N are?

  1. A. N = 2*L
  2. B. N = L + 1
  3. C. N = L - 1
  4. D. N = 2*L - 1
Report Error

Figure below is a balanced binary tree. If a node inserted as child of the node R, how many nodes will become unbalanced?

  1. A. 2
  2. B. 1
  3. C. 3
  4. D. 0
Report Error

The maximum number of nodes in a tree for which post-order and pre-order traversals may be equal is . . . . . . . .

  1. A. 3
  2. B. 1
  3. C. 2
  4. D. any number
Report Error

What is the maximum height of an AVL tree with p nodes?

  1. A. p
  2. B. log(p)
  3. C. log(p)/2
  4. D. p / 2
Report Error