CommerceBinary Search TreesB Tree MCQs
Practice Binary Search TreesB Tree MCQs for competitive exams.
Binary Search TreesB Tree MCQs
Practice questions from this topic.
Cartesian trees solve range minimum query problem in constant time.
- A. true
- B. false
Correct Answer: A
How many children does a binary tree have?
- A. 2
- B. any number of children
- C. 0 or 1 or 2
- D. 0 or 1
Correct Answer: C
Select the code snippet which performs post-order traversal.
- A. public void postorder(Tree root) { System.out.println(root.data); postorder(root.left); postorder(root.right); }
- B. public void postorder(Tree root) { postorder(root.left); postorder(root.right); System.out.println(root.data); }
- C. public void postorder(Tree root) { System.out.println(root.data); postorder(root.right); postorder(root.left); }
- D. public void postorder(Tree root) { postorder(root.right); System.out.println(root.data); postorder(root.left); }
Correct Answer: B
A binary tree is a rooted tree but not an ordered tree.
- A. true
- B. false
Correct Answer: B
Given an empty AVL tree, how would you construct AVL tree when a set of numbers are given without performing any rotations?
- A. just build the tree with the given input
- B. find the median of the set of elements given, make it as root and construct the tree
- C. use trial and error
- D. use dynamic programming to build the tree
Correct Answer: B
What is the condition for a tree to be weight balanced. where a is factor and n is a node?
- A. weight[n.left] >= a*weight[n] and weight[n.right] >= a*weight[n].
- B. weight[n.left] >= a*weight[n.right] and weight[n.right] >= a*weight[n].
- C. weight[n.left] >= a*weight[n.left] and weight[n.right] >= a*weight[n].
- D. weight[n] is a non zero
Correct Answer: A
Which of the following options is an application of splay trees?
- A. cache Implementation
- B. networks
- C. send values
- D. receive values
Correct Answer: A
What is the longest length path for a node x in random binary search tree for the insertion process?
- A. log x
- B. x 2
- C. x!
- D. 4.311 log x
Correct Answer: D
What is the condition for priority of a node in a treap?
- A. a node's priority should be greater than its parent
- B. a node's priority should be at least as large as its parent
- C. the priority is randomly assigned and can have any value
- D. a node's priority is always given in decreasing order
Correct Answer: B
Which algorithm is used in the top tree data structure?
- A. Divide and Conquer
- B. Greedy
- C. Backtracking
- D. Branch
Correct Answer: A
AVL trees are more balanced than Red-black trees.
- A. True
- B. False
Correct Answer: A
Why is heap implemented using array representations than tree(linked list) representations though both tree representations and heaps have same complexities? for binary heap -insert: O(log n) -delete min: O(log n) for a tree -insert: O(log n) -delete: O(log n) Then why go with array representation when both are having same values ?
- A. arrays can store trees which are complete and heaps are not complete
- B. lists representation takes more memory hence memory efficiency is less and go with arrays and arrays have better caching
- C. lists have better caching
- D. In lists insertion and deletion is difficult
Correct Answer: B