CommerceBinary Search TreesB Tree MCQs
Practice Binary Search TreesB Tree MCQs for competitive exams.
Binary Search TreesB Tree MCQs
Practice questions from this topic.
In a full binary tree if number of internal nodes is I, then number of leaves L are?
- A. L = 2*I
- B. L = I + 1
- C. L = I - 1
- D. L = 2*I - 1
Correct Answer: B
Find the postorder traversal of the binary tree shown below.
- A. P Q R S T U V W X
- B. W R S Q P V T U X
- C. S W T Q X U V R P
- D. S T W U X V Q R P
Correct Answer: C
What is the special property of red-black trees and what root should always be?
- A. a color which is either red or black and root should always be black color only
- B. height of the tree
- C. pointer to next node
- D. a color which is either green or black
Correct Answer: A
To obtain a prefix expression, which of the tree traversals is used?
- A. Level-order traversal
- B. Pre-order traversal
- C. Post-order traversal
- D. In-order traversal
Correct Answer: B
What is a Cartesian tree?
- A. a skip list in the form of tree
- B. a tree which obeys cartesian product
- C. a tree which obeys heap property and whose inorder traversal yields the given sequence
- D. a tree which obeys heap property only
Correct Answer: C
What output does the below pseudo code produces? Tree_node function(Tree_node x) { Tree_node y = x.left; x.left = y.right; y.right = x; return y; }
- A. right rotation of subtree
- B. left rotation of subtree
- C. zig-zag operation
- D. zig-zig operation
Correct Answer: A
A self - balancing binary search tree can be used to implement . . . . . . . .
- A. Priority queue
- B. Hash table
- C. Heap sort
- D. Priority queue and Heap sort
Correct Answer: A
Why to prefer red-black trees over AVL trees?
- A. Because red-black is more rigidly balanced
- B. AVL tree store balance factor in every node which costs space
- C. AVL tree fails at scale
- D. Red black is more efficient
Correct Answer: B
What is the priority of a null node?
- A. 1
- B. 0
- C. random number
- D. infinity
Correct Answer: D
Select the code snippet which performs in-order traversal.
- A. public void inorder(Tree root) { System.out.println(root.data); inorder(root.left); inorder(root.right); }
- B. public void inorder(Tree root) { inorder(root.left); System.out.println(root.data); inorder(root.right); }
- C. public void inorder(Tree root) { System.out.println(root.data); inorder(root.right); inorder(root.left); }
- D. public void inorder(Tree root) { inorder(root.right); inorder(root.left); System.out.println(root.data); }
Correct Answer: B
What is the worst case analysis of an AA-Tree?
- A. O(N)
- B. O(log N)
- C. O( N log N)
- D. O(N 2 )
Correct Answer: B
Which of the following is an application of Red-black trees and why?
- A. used to store strings efficiently
- B. used to store integers efficiently
- C. can be used in process schedulers, maps, sets
- D. for efficient sorting
Correct Answer: C