Commerce

Binary 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()); }

  1. A. Preorder traversal
  2. B. Inorder traversal
  3. C. Postorder traversal
  4. D. Level order traversal
Report Error

Balanced binary tree with n items allows the lookup of an item in . . . . . . . . worst-case time.

  1. A. O(log n)
  2. B. O(nlog 2)
  3. C. O(n)
  4. D. O(1)
Report Error

How many randomized binary search trees can be formed by the numbers (1, 3, 2)?

  1. A. 2
  2. B. 3
  3. C. 6
  4. D. 5
Report Error

What is a complete binary tree?

  1. A. Each node has exactly zero or two children
  2. B. A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from right to left
  3. C. A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from left to right
  4. D. A tree In which all nodes have degree 2
Report Error

For how many vertices in a set, is top tree defined for underlying tree?

  1. A. 3
  2. B. 4
  3. C. 5
  4. D. 2
Report Error

Which type of binary search tree or algorithm does tango tree use?

  1. A. Online
  2. B. Offline
  3. C. Static
  4. D. Dynamic
Report Error

When to choose Red-Black tree, AVL tree and B-trees?

  1. A. many inserts, many searches and when managing more items respectively
  2. B. many searches, when managing more items respectively and many inserts respectively
  3. C. sorting, sorting and retrieval respectively
  4. D. retrieval, sorting and retrieval respectively
Report Error

Which of the following is not the self balancing binary search tree?

  1. A. AVL Tree
  2. B. 2-3-4 Tree
  3. C. Red - Black Tree
  4. D. Splay Tree
Report Error

A node of the weight balanced tree has

  1. A. key, left and right pointers, size
  2. B. key, value
  3. C. key, size
  4. D. key
Report Error

Select the code snippet which performs pre-order traversal.

  1. A. public void preorder(Tree root) { System.out.println(root.data); preorder(root.left); preorder(root.right); }
  2. B. public void preorder(Tree root) { preorder(root.left); System.out.println(root.data); preorder(root.right); }
  3. C. public void preorder(Tree root) { System.out.println(root.data); preorder(root.right); preorder(root.left); }
  4. D. public void preorder(Tree root) { preorder(root.right); preorder(root.left); System.out.println(root.data); }
Report Error

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

  1. A. insert a new node
  2. B. delete a node
  3. C. search a node
  4. D. count the number of nodes
Report Error

What maximum difference in heights between the leafs of a AVL tree is possible?

  1. A. log(n) where n is the number of nodes
  2. B. n where n is the number of nodes
  3. C. 0 or 1
  4. D. atmost 1
Report Error