CommerceBinary 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?
- A. height of a splay tree can be linear when accessing elements in non decreasing order.
- B. splay operations are difficult
- C. no significant disadvantage
- D. splay tree performs unnecessary splay when a node is only being read
Correct Answer: A
When it would be optimal to prefer Red-black trees over AVL trees?
- A. when there are more insertions or deletions
- B. when more search is needed
- C. when tree must be balanced
- D. when log(nodes) time complexity is needed
Correct Answer: A
For the tree below, write the level-order traversal.
- A. 2, 7, 2, 6, 5, 11, 5, 9, 4
- B. 2, 7, 5, 2, 11, 9, 6, 5, 4
- C. 2, 5, 11, 6, 7, 4, 9, 5, 2
- D. 2, 7, 5, 6, 11, 2, 5, 4, 9
Correct Answer: B
Why we need to a binary tree which is height balanced?
- A. to avoid formation of skew trees
- B. to save memory
- C. to attain faster memory access
- D. to simplify storing
Correct Answer: A
What is the space complexity of a treap algorithm?
- A. O(N)
- B. O(log N)
- C. O(N log N)
- D. O(N 2 )
Correct Answer: A
Is it true that splay trees have O(logn) amortized complexity ?
- A. true
- B. false
Correct Answer: A
Can a tree stored in an array using either one of inorder or post order or pre order traversals be again reformed?
- A. Yes just traverse through the array and form the tree
- B. No we need one more traversal to form a tree
- C. No in case of sparse trees
- D. Yes by using both inorder and array elements
Correct Answer: B
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)
- A. when x>t. element Rotate-with-left-child should take place and vice versa
- B. the logic is incorrect
- C. the condition for rotating children is wrong
- D. insertion cannot be performed in weight balanced trees
Correct Answer: A
In a full binary tree if there are L leaves, then total number of nodes N are?
- A. N = 2*L
- B. N = L + 1
- C. N = L - 1
- D. N = 2*L - 1
Correct Answer: D
Figure below is a balanced binary tree. If a node inserted as child of the node R, how many nodes will become unbalanced?
- A. 2
- B. 1
- C. 3
- D. 0
Correct Answer: B
The maximum number of nodes in a tree for which post-order and pre-order traversals may be equal is . . . . . . . .
- A. 3
- B. 1
- C. 2
- D. any number
Correct Answer: B
What is the maximum height of an AVL tree with p nodes?
- A. p
- B. log(p)
- C. log(p)/2
- D. p / 2
Correct Answer: B