CommerceBinary Search TreesB Tree MCQs
Practice Binary Search TreesB Tree MCQs for competitive exams.
Binary Search TreesB Tree MCQs
Practice questions from this topic.
Who is the inventor of AA-Tree?
- A. Arne Andersson
- B. Daniel Sleator
- C. Rudolf Bayer
- D. Jon Louis Bentley
Correct Answer: A
Which process forms the randomized binary search tree?
- A. Stochastic Process
- B. Branching Process
- C. Diffusion Process
- D. Aggregation Process
Correct Answer: A
Of the following rules that are followed by an AA-tree, which of the following is incorrect? 1. Only right children can be red 2. Procedures are coded recursively 3. Instead of storing colors, the level of a node is stored 4. There should not be any left children
- A. 1
- B. 2
- C. 3
- D. 4
Correct Answer: D
In postorder traversal of binary tree right subtree is traversed before visiting root.
- A. True
- B. False
Correct Answer: A
What is the traversal strategy used in the binary tree?
- A. depth-first traversal
- B. breadth-first traversal
- C. random traversal
- D. Priority traversal
Correct Answer: B
What happens if we apply the below operations on an input sequence? i. construct a cartesian tree for input sequence ii. put the root element of above tree in a priority queue iii. if( priority queue is not empty) then iv. search and delete minimum value in priority queue v. add that to output vi. add cartesian tree children of above node to priority queue
- A. constructs a cartesian tree
- B. sorts the input sequence
- C. does nothing
- D. produces some random output
Correct Answer: B
What are the worst case and average case complexities of a binary search tree?
- A. O(n), O(n)
- B. O(logn), O(logn)
- C. O(logn), O(n)
- D. O(n), O(logn)
Correct Answer: D
What will be the height of a balanced full binary tree with 8 leaves?
- A. 8
- B. 5
- C. 6
- D. 4
Correct Answer: D
Given that 2 elements are present in the tree, write a function to find the LCA(Least Common Ancestor) of the 2 elements.
- A. public void lca(Tree root,int n1, int n2) { while (root != NULL) { if (root.data() > n1 && root.data() > n2) root = root.right(); else if (root.data() < n1 && root.data() < n2) root = root.left(); else break; } System.out.println(root.data()); }
- B. public void lca(Tree root,int n1, int n2) { while (root != NULL) { if (root.data() > n1 && root.data() < n2) root = root.left(); else if (root.data() n2) root = root.right(); else break; } System.out.println(root.data()); }
- C. public void lca(Tree root,int n1, int n2) { while (root != NULL) { if (root.data() > n1 && root.data() > n2) root = root.left(); else if (root.data() < n1 && root.data() < n2) root = root.right(); else break; } System.out.println(root.data()); }
- D. public void lca(Tree root,int n1, int n2) { while (root != NULL) { if (root.data() > n1 && root.data() > n2) root = root.left.left(); else if (root.data() < n1 && root.data() < n2) root = root.right.right(); else break; } System.out.println(root.data()); }
Correct Answer: C
To restore the AVL property after inserting a element, we start at the insertion point and move towards root of that tree. is this statement true?
- A. true
- B. false
Correct Answer: A
In general, the node content in a threaded binary tree is . . . . . . . .
- A. leftchild_pointer, left_tag, data, right_tag, rightchild_pointer
- B. leftchild_pointer, left_tag
- C. leftchild_pointer, left_tag, right_tag, rightchild_pointer
- D. leftchild_pointer, left_tag, data
Correct Answer: A
What are the operations that could be performed in O(logn) time complexity by red-black tree?
- A. insertion, deletion, finding predecessor, successor
- B. only insertion
- C. only finding predecessor, successor
- D. for sorting
Correct Answer: A