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 does the following piece of code do? public void func(Tree root) { System.out.println(root.data()); func(root.left()); func(root.right()); }
- A. Preorder traversal
- B. Inorder traversal
- C. Postorder traversal
- D. Level order traversal
Correct Answer: A
Balanced binary tree with n items allows the lookup of an item in . . . . . . . . worst-case time.
- A. O(log n)
- B. O(nlog 2)
- C. O(n)
- D. O(1)
Correct Answer: A
How many randomized binary search trees can be formed by the numbers (1, 3, 2)?
- A. 2
- B. 3
- C. 6
- D. 5
Correct Answer: D
What is a complete binary tree?
- A. Each node has exactly zero or two children
- B. A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from right to left
- C. A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from left to right
- D. A tree In which all nodes have degree 2
Correct Answer: C
For how many vertices in a set, is top tree defined for underlying tree?
- A. 3
- B. 4
- C. 5
- D. 2
Correct Answer: D
Which type of binary search tree or algorithm does tango tree use?
- A. Online
- B. Offline
- C. Static
- D. Dynamic
Correct Answer: A
When to choose Red-Black tree, AVL tree and B-trees?
- A. many inserts, many searches and when managing more items respectively
- B. many searches, when managing more items respectively and many inserts respectively
- C. sorting, sorting and retrieval respectively
- D. retrieval, sorting and retrieval respectively
Correct Answer: A
Which of the following is not the self balancing binary search tree?
- A. AVL Tree
- B. 2-3-4 Tree
- C. Red - Black Tree
- D. Splay Tree
Correct Answer: B
A node of the weight balanced tree has
- A. key, left and right pointers, size
- B. key, value
- C. key, size
- D. key
Correct Answer: A
Select the code snippet which performs pre-order traversal.
- A. public void preorder(Tree root) { System.out.println(root.data); preorder(root.left); preorder(root.right); }
- B. public void preorder(Tree root) { preorder(root.left); System.out.println(root.data); preorder(root.right); }
- C. public void preorder(Tree root) { System.out.println(root.data); preorder(root.right); preorder(root.left); }
- D. public void preorder(Tree root) { preorder(root.right); preorder(root.left); System.out.println(root.data); }
Correct Answer: A
What is the below pseudo code trying to do, where pt is a node pointer and root pointer? redblack(Node root, Node pt) : if (root == NULL) return pt if (pt.data root.data) { root.right = redblackt(root.right, pt) root.right.parent = root } return root
- A. insert a new node
- B. delete a node
- C. search a node
- D. count the number of nodes
Correct Answer: A
What maximum difference in heights between the leafs of a AVL tree is possible?
- A. log(n) where n is the number of nodes
- B. n where n is the number of nodes
- C. 0 or 1
- D. atmost 1
Correct Answer: A