# Data Structures MCQ|Non Linear Data Structures – Trees

A. 0

B. 1

C. 2

D. 3

## 2. The following given tree is an example for?

A. Binary tree

B. Binary search tree

C. Fibonacci tree

D. none

A. 1

B. 2

C. 3

D. 4

## 4. What is the traversal strategy used in the binary tree?

A. depth-first traversal

C. random traversal

D. Priority traversal

A. 1

B. 2

C. 3

D. 4

## 6. What operation does the following diagram depict?

A. inserting a leaf node

B. inserting an internal node

C. deleting a node with 0 or 1 child

D. none

Answer: C.deleting a node with 0 or 1 child

A. n+O(n)

B. 2n+O(n)

C. n/2

D. n

A. O(N)

B. O(√N)

C. O(N2)

D. O(log N)

A. 1

B. 4

C. 2

D. 3

A. 2i+1

B. 2i+2

C. 2i

A. (i+1)/2

B. (i-1)/2

C. i/2

D. 2i/2

## 12. Which of the following properties are obeyed by all three tree – traversals?

A. Left subtrees are visited before right subtrees

B. Right subtrees are visited before left subtrees

C. Root node is visited before left subtree

D. Root node is visited before right subtree

Answer: A.Left subtrees are visited before right subtrees

## 13. For the tree below, write the pre-order traversal.

A. 2, 7, 2, 6, 5, 11, 5, 9, 4

B. 2, 7, 5, 2, 6, 9, 5, 11, 4

C. 2, 5, 11, 6, 7, 4, 9, 5, 2

D. none

Answer: A.2, 7, 2, 6, 5, 11, 5, 9, 4

## 14. For the tree below, write the post-order traversal.

A. 2, 7, 2, 6, 5, 11, 5, 9, 4

B. 2, 7, 5, 2, 6, 9, 5, 11, 4

C. 2, 5, 11, 6, 7, 4, 9, 5, 2

D. none

Answer: C.2, 5, 11, 6, 7, 4, 9, 5, 2

A. O(1)

B. O(n)

C. O(logn)

D. O(nlogn)

A. O(1)

B. O(nlogd)

C. O(logd)

D. O(d)

## 17. 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

## 18. Consider the following data. The pre order traversal of a binary tree is A, B, E, C, D. The in ordertraversal of the same binary tree is B, E, A, D, C. The level order sequence for the binary tree is

A. A, C, D, B, E

B. A, B, C, D, E

C. A, B, C, E, D

D. D, B, E, A, C

Answer: B.A, B, C, D, E

A. 15

B. 3

C. 5

D. 8

## 20. The post-order traversal of a binary tree is O P Q R S T. Then possible pre-order traversal will be

A. T Q R S O P

B. T O Q R P S

C. T Q O P S R

D. T Q O S P R

Answer: C.T Q O P S R

## 21. A binary search tree contains values 7, 8, 13, 26, 35, 40, 70, 75. Which one of the following is a validpost-order sequence of the tree provided the pre-order sequence as 35, 13, 7, 8, 26, 70, 40 and 75?

A. 7, 8, 26, 13, 75, 40, 70, 35

B. 26, 13, 7, 8, 70, 75, 40, 35

C. 7, 8, 13, 26, 35, 40, 70, 75

D. 8, 7, 26, 13, 40, 75, 70, 35

Answer: D.8, 7, 26, 13, 40, 75, 70, 35

## 22. Which of the following pair’s traversals on a binary tree can build the tree uniquely?

A. post-order and pre-order

B. post-order and in-order

C. post-order and level order

D. level order and preorder

## 23. A full binary tree can be generated using

A. post-order and pre-order traversal

B. pre-order traversal

C. post-order traversal

D. in-order traversal

A. 3

B. 1

C. 2

D. any number

## 25. The pre-order and in-order are traversals of a binary tree are T M L N P O Q and L M N T O P Q.Which of following is post-order traversal of the tree?

A. L N M O Q P T

B. N M O P O L T

C. L M N O P Q T

D. O P L M N Q T

Answer: A.L N M O Q P T

## 26. 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. none

Answer: C.S W T Q X U V R P

## 27. For the tree below, write the in-order traversal.

A. 6, 2, 5, 7, 11, 2, 5, 9, 4

B. 6, 5, 2, 11, 7, 4, 9, 5, 2

C. 2, 7, 2, 6, 5, 11, 5, 9, 4

D. none

Answer: A.6, 2, 5, 7, 11, 2, 5, 9, 4

## 28. For the tree below, write the level-order traversal.

A. 2, 7, 2, 6, 5, 11, 5, 9, 4

B. 2, 7, 5, 2, 11, 9, 6, 5, 4

C. 2, 5, 11, 6, 7, 4, 9, 5, 2

D. none

Answer: B.2, 7, 5, 2, 11, 9, 6, 5, 4

A. O(1)

B. O(nlogd)

C. O(logd)

D. O(d)

A. O(1)

B. O(n)

C. O(logn)

D. O(nlogn)

## 31. Which of the following graph traversals closely imitates level order traversal of a binary tree?

A. Depth First Search

C. Depth & Breadth First Search

D. Binary Search

## 32. In a binary search tree, which of the following traversals would print the numbers in the ascendingorder?

A. Level-order traversal

B. Pre-order traversal

C. Post-order traversal

D. In-order traversal

A. Height

B. Depth

C. Length

D. Width

A. Height

B. Depth

C. Length

D. Width

## 35. What is a full binary tree?

A. Each node has exactly zero or two children

B. Each node has exactly two children

C. All the leaves are at the same level

D. Each node has exactly one or two children

Answer: A.Each node has exactly zero or two children

## 36. 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

Answer: C.A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from left to right

## 37. What is the average case time complexity for finding the height of the binary tree?

A. h = O(loglogn)

B. h = O(nlogn)

C. h = O(n)

D. h = O(log n)

## 38. Which of the following is not an advantage of trees?

A. Hierarchical structure

B. Faster search

C. Router algorithms

D. Undo/Redo operations in a notepad

## 39. 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

Answer: B.L = I + 1

## 40. In a full binary tree if number of internal nodes is I, then number of nodes N are?

A. N = 2*I

B. N = I + 1

C. N = I – 1

D. N = 2*I + 1

Answer: D.N = 2*I + 1

## 41. In a full binary tree if there are L leaves, then total number of nodes N are?

A. N = 2*L

B. N = L + 1

C. N = L – 1

D. N = 2*L – 1Answer: D.N = 2*L – 1

## 42. Which of the following is incorrect with respect to binary trees?

A. Let T be a binary tree. For every k ≥ 0, there are no more than 2k nodes in level k

B. Let T be a binary tree with λ levels. Then T has no more than 2λ – 1 nodes

C. Let T be a binary tree with N nodes. Then the number of levels is at least ceil(log (N + 1))

D. Let T be a binary tree with N nodes. Then the number of levels is at least floor(log (N + 1))

Answer: D.Let T be a binary tree with N nodes. Then the number of levels is at least floor(log (N + 1))

## 43. Which of the following is false about a binary search tree?

A. The left child is always lesser than its parent

B. The right child is always greater than its parent

C. The left and right sub-trees should also be binary search trees

D. In order sequence gives decreasing order of elements

Answer: D.In order sequence gives decreasing order of elements

## 44. What is the speciality about the inorder traversal of a binary search tree?

A. It traverses in a non increasing order

B. It traverses in an increasing order

C. It traverses in a random fashion

D. It traverses based on priority of the node

Answer: B.It traverses in an increasing order

## 45. 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)

## 46. What are the conditions for an optimal binary search tree and what is its advantage?

A. The tree should not be modified and you should know how often the keys are accessed, it improves the lookup cost

B. You should know the frequency of access of the keys, improves the lookup time

C. The tree can be modified and you should know the number of elements in the tree before hand, it improves the deletion time

D. The tree should be just modified and improves the lookup time

Answer: A.The tree should not be modified and you should know how often the keys are accessed, it improves the lookup cost

## 47. 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

A. O(n log n)

B. O(n)

C. O(n2)

D. O(log n)

A. At least one

B. At most one

C. Two

D. At most two

## 50. Associative arrays can be implemented using

A. B-tree

D. A self balancing binary search tree

Answer: D.A self balancing binary search tree

A. 2-3 tree

C. AA tree

D. Treap

## 52. 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

## 53. In which of the following self – balancing binary search tree the recently accessed element can beaccessed quickly?

A. AVL tree

B. AA tree

C. Splay tree

D. Red – Black tree

A. log2(n)

B. n

C. 2n + 1

D. 2n – 1

## 55. What is an AVL tree?

A. a tree which is balanced and is a height balanced tree

B. a tree which is unbalanced and is a height balanced tree

C. a tree with three children

D. a tree with atmost 3 children

Answer: A.a tree which is balanced and is a height balanced tree

## 56. Why we need to a binary tree which is height balanced?

A. to avoid formation of skew trees

B. to save memory

C. to attain faster memory access

D. to simplify storing

Answer: A.to avoid formation of skew trees

A. p

B. log(p)

C. log(p)/2

D. P⁄2

## 58. Given an empty AVL tree, how would you construct AVL tree when a set of numbers are givenwithout 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

Answer: B.find the median of the set of elements given, make it as root and construct the tree

## 59. 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

Answer: A.log(n) where n is the number of nodes

## 60. What is missing?

A. Height(w-left), x-height

B. Height(w-right), x-height

C. Height(w-left), x

D. Height(w-left)

## 61. 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

Answer: B.AVL tree store balance factor in every node which costs space

## 62. Which of the following is the most widely used external memory data structure?

A. AVL tree

B. B-tree

C. Red-black tree

D. Both AVL tree and Red-black tree

## 63. B-tree of order n is a order-n multiway tree in which each non-root node contains

A. at most (n – 1)/2 keys

B. exact (n – 1)/2 keys

C. at least 2n keys

D. at least (n – 1)/2 keys

Answer: D.at least (n – 1)/2 keys

A. 255

B. 63

C. 127

D. 188

A. 14

B. 7

C. 11

D. 5

A. AVL

B. AA

C. 2-3

D. Red-Black

## 67. What is the best case height of a B-tree of order n and which has k keys?

A. logn (k+1) – 1

B. nk

C. logk (n+1) – 1

D. klogn

## 68. Which of the following is true?

A. larger the order of B-tree, less frequently the split occurs

B. larger the order of B-tree, more frequently the split occurs

C. smaller the order of B-tree, more frequently the split occurs

D. smaller the order of B-tree, less frequently the split occurs

Answer: A.larger the order of B-tree, less frequently the split occurs

## 69. In a max-heap, element with the greatest key is always in the which node?

A. Leaf node

B. First node of left sub tree

C. root node

D. First node of right sub tree

## 70. What is the complexity of adding an element to the heap

A. O(log n)

B. O(h)

C. O(log n) & O(h)

D. O(n)

A. O(logn)

B. O(n)

C. O(nlogn)

D. O(n2)

## 72. Heap can be used as

A. Priority queue

B. Stack

C. A decreasing order array

D. Normal Array

A. 2

B. 100

C. 17

D. none

## 74. An array consists of n elements. We want to create a heap using the elements. The time complexityof building a heap will be in order of

A. O(n*n*logn)

B. O(n*logn)

C. O(n*n)

D. O(n *logn *logn)