1. | What is the maximum number of children that a binary tree node can have? |
A. | 0 |
B. | 1 |
C. | 2 |
D. | 3 |
Answer» C. 2 |
2. | The following given tree is an example for? |
A. | Binary tree |
B. | Binary search tree |
C. | Fibonacci tree |
D. | none |
Answer» A. Binary tree |
3. | How many common operations are performed in a binary tree? |
A. | 1 |
B. | 2 |
C. | 3 |
D. | 4 |
Answer» C. 3 |
4. | What is the traversal strategy used in the binary tree? |
A. | depth-first traversal |
B. | breadth-first traversal |
C. | random traversal |
D. | Priority traversal |
Answer» B. breadth-first traversal |
5. | How many types of insertion are performed in a binary tree? |
A. | 1 |
B. | 2 |
C. | 3 |
D. | 4 |
Answer» B. 2 |
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 |
7. | How many bits would a succinct binary tree occupy? |
A. | n+O(n) |
B. | 2n+O(n) |
C. | n/2 |
D. | n |
Answer» B. 2n+O(n) |
8. | The average depth of a binary tree is given as? |
A. | O(N) |
B. | O(√N) |
C. | O(N2) |
D. | O(log N) |
Answer» D. O(log N) |
9. | How many orders of traversal are applicable to a binary tree (In General)? 3 |
A. | 1 |
B. | 4 |
C. | 2 |
D. | 3 |
Answer» D. 3 |
10. | If binary trees are represented in arrays, what formula can be used to locate a left child, if the node has an index i? |
A. | 2i+1 |
B. | 2i+2 |
C. | 2i |
D. | 4i |
Answer» A. 2i+1 |
11. | Using what formula can a parent node be located in an array? |
A. | (i+1)/2 |
B. | (i-1)/2 |
C. | i/2 |
D. | 2i/2 |
Answer» B. (i-1)/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 |
15. | What is the time complexity of pre-order traversal in the iterative fashion? |
A. | O(1) |
B. | O(n) |
C. | O(logn) |
D. | O(nlogn) |
Answer» B. O(n) |
16. | What is the space complexity of the post-order traversal in the recursive fashion? (d is the tree depth and n is the number of nodes) |
A. | O(1) |
B. | O(nlogd) |
C. | O(logd) |
D. | O(d) |
Answer» 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 |
Answer» B. Pre-order traversal |
18. | Consider the following data. The pre order traversal of a binary tree is A, B, E, C, D. The in order traversal 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 |
19. | What is the possible number of binary trees that can be created with 3 nodes, giving the sequence N, M, L when traversed in post-order. |
A. | 15 |
B. | 3 |
C. | 5 |
D. | 8 |
Answer» C. 5 |
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 valid post-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 |
Answer» B. post-order and in-order |
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 |
Answer» A. post-order and pre-order traversal |
24. | The maximum number of nodes in a tree for which post-order and pre-order traversals may be equal is |
A. | 3 |
B. | 1 |
C. | 2 |
D. | any number |
Answer» B. 1 |
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 |
29. | What is the space complexity of the in-order traversal in the recursive fashion? (d is the tree depth and n is the number of nodes) |
A. | O(1) |
B. | O(nlogd) |
C. | O(logd) |
D. | O(d) |
Answer» D. O(d) |
30. | What is the time complexity of level order traversal? |
A. | O(1) |
B. | O(n) |
C. | O(logn) |
D. | O(nlogn) |
Answer» B. O(n) |
31. | Which of the following graph traversals closely imitates level order traversal of a binary tree? |
A. | Depth First Search |
B. | Breadth First Search |
C. | Depth & Breadth First Search |
D. | Binary Search |
Answer» B. Breadth First Search |
32. | In a binary search tree, which of the following traversals would print the numbers in the ascending order? |
A. | Level-order traversal |
B. | Pre-order traversal |
C. | Post-order traversal |
D. | In-order traversal |
Answer» D. In-order traversal |
33. | The number of edges from the root to the node is called of the tree. |
A. | Height |
B. | Depth |
C. | Length |
D. | Width |
Answer» B. Depth |
34. | The number of edges from the node to the deepest leaf is called of the tree. |
A. | Height |
B. | Depth |
C. | Length |
D. | Width |
Answer» A. Height |
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) |
Answer» 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 |
Answer» 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 – 1 |
Answer» 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) |
Answer» 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 |
Answer» B. 2-3-4 Tree |
48. | The binary tree sort implemented using a self – balancing binary search tree takes time is worst case. |
A. | O(n log n) |
B. | O(n) |
C. | O(n2) |
D. | O(log n) |
Answer» A. O(n log n) |
49. | An AVL tree is a self – balancing binary search tree, in which the heights of the two child sub trees of any node differ by |
A. | At least one |
B. | At most one |
C. | Two |
D. | At most two |
Answer» B. At most one |
51. | Which of the following is a self – balancing binary search tree? |
A. | 2-3 tree |
B. | Threaded binary tree |
C. | AA tree |
D. | Treap |
Answer» C. AA tree |
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 |
Answer» A. Priority queue |
53. | In which of the following self – balancing binary search tree the recently accessed element can be accessed quickly? |
A. | AVL tree |
B. | AA tree |
C. | Splay tree |
D. | Red – Black tree |
Answer» C. Splay tree |
54. | The minimum height of self balancing binary search tree with n nodes is |
A. | log2(n) |
B. | n |
C. | 2n + 1 |
D. | 2n – 1 |
Answer» A. log2(n) |
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 |
57. | What is the maximum height of an AVL tree with p nodes? |
A. | p |
B. | log(p) |
C. | log(p)/2 |
D. | P⁄2 |
Answer» B. log(p) |
58. | Given an empty AVL tree, how would you construct AVL tree when a set of numbers are given without 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) |
Answer» A. Height(w-left), x-height |
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 |
Answer» B. B-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 |
64. | A B-tree of order 4 and of height 3 will have a maximum of keys. |
A. | 255 |
B. | 63 |
C. | 127 |
D. | 188 |
Answer» A. 255 |
65. | Five node splitting operations occurred when an entry is inserted into a B-tree. Then how many nodes are written? |
A. | 14 |
B. | 7 |
C. | 11 |
D. | 5 |
Answer» C. 11 |
66. | trees are B-trees of order 4. They are an isometric of trees. |
A. | AVL |
B. | AA |
C. | 2-3 |
D. | Red-Black |
Answer» 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 |
Answer» A. logn (k+1) – 1 |
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 |
Answer» C. root node |
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) |
Answer» C. O(log n) & O(h) |
71. | The worst case complexity of deleting any arbitrary node value element from heap is |
A. | O(logn) |
B. | O(n) |
C. | O(nlogn) |
D. | O(n2) |
Answer» A. O(logn) |
72. | Heap can be used as |
A. | Priority queue |
B. | Stack |
C. | A decreasing order array |
D. | Normal Array |
Answer» A. Priority queue |
73. | If we implement heap as min-heap, deleting root node (value 1)from the heap. What would be the value of root node after second iteration if leaf node (value 100) is chosen to replace the root at start. |
A. | 2 |
B. | 100 |
C. | 17 |
D. | none |
Answer» A. 2 |
74. | An array consists of n elements. We want to create a heap using the elements. The time complexity of 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) |
Answer» B. O(n*logn) |
Tags
Question and answers in Non Linear Data Structures – Trees,Non Linear Data Structures – Trees Multiple choice questions and answers,Non Linear Data Structures – Trees Important MCQs,Solved MCQs for Non Linear Data Structures – Trees,Non Linear Data Structures – Trees MCQs with answers PDF download