40 MCQs of Advance Data Structure1) What is the load factor for an open addressing technique?
Answer: c) 0.5 Explanation: 2) For the given hash table, in what location will the element 58 be hashed using quadratic probing? 0 49 1 2 3 4 5 6 7 8 18 9 89
Answer: b) 2 Explanation: 3) Which one of the following data structures are preferred in database-system implementation?
Answer: c) B+ - tree Explanation: 4) Consider a hash table of size seven, with starting index zero, and a hash function (3x + 4)mod7. Assuming the hash table is initially empty, which of the following is the contents of the table when the sequence 1, 3, 8, 10 is inserted into the table using closed hashing? Note that '_' denotes an empty location in the table.
Answer: b) 1, 8, 10, _, _, _, 3 Explanation: 5) What maximum difference in heights between the leafs of a AVL tree is possible?
Answer: a) log(n) where n is the number of nodes Explanation: 6) How can you save memory when storing color information in Red-Black tree?
Answer: a) using least significant bit of one of the pointers in the node for color information Explanation: 7) What are the worst case and average case complexities of a binary search tree?
Answer: d) O(n), O(log n) Explanation: 8) Which of the following is the efficient data structure for searching words in dictionaries?
Answer: d) trie Explanation: 9) In the following given hash table, use linear probing to find the location of 49. 0 1 2 3 4 5 6 7 8 18 9 89
Answer: d) 0 Explanation: 10) When we have red-black trees and AVL trees that can perform most of operations in logarithmic times, then what is the need for splay trees?
Answer: b) In real time it is estimated that 80% access is only to 20% data, hence most used ones must be easily available Explanation: 11) We are given a set of n distinct elements and an unlabelled binary tree with n nodes. In how many ways can we populate the tree with the given set so that it becomes a binary search tree?
Answer: b) 1 Explanation: 12) Which of the following is true?
Answer: a) larger the order of B-tree, less frequently the split occurs Explanation: 13) If h is chosen from a universal collection of hash functions and is used to hash n keys into a table of size m, where n ≤ m, the expected number of collisions involving a particular key x is less than _______.
Answer: a) 1 Explanation: 14) Five node splitting operations occurred when an entry is inserted into a B-tree. Then how many nodes are written?
Answer: c) 11 Explanation: 15) A dictionary has a set of ------- and each key has a single associated value.
Answer: a) Keys Explanation: 16) Consider a hash table of size seven, with starting index zero, and a hash function (3x + 4)mod7. Assuming the hash table is initially empty, which of the following is the contents of the table when the sequence 1, 3, 8, 10 is inserted into the table using closed hashing? Note that '_' denotes an empty location in the table.
Answer: b) 1 8 10 - - - 3 Explanation: 17) Consider the below left-left rotation pseudo code where the node contains value pointers to left, right child nodes and a height value and Height() function returns height value stored at a particular node. avltree leftrotation(avltreenode z): avltreenode w =x-left x-left=w-right w-right=x x-height=max(Height(x-left),Height(x-right))+1 w-height=max(missing)+1 return w What is missing?
Answer: a) Height(w-left), x-height Explanation: 18) Which hashing technique is free from clustering?
Answer: b) Double hashing Explanation: 19) We are given a set of n distinct elements and an unlabelled binary tree with n nodes. In how many ways can we populate the tree with the given set so that it becomes a binary search tree?
Answer: b) 1 Explanation: 20) Which hash function is used in the division method?
Answer: b) h(k) = k mod m Explanation: 21) When it would be optimal to prefer Red-black trees over AVL trees?
Answer: a) when there are more insertions or deletions Explanation: 22) In the balanced binary tree in Fig. given below, how many nodes will become unbalanced when a node is inserted as a child of the node "g"?
Answer: b) 3 Explanation: 23) What is the special property of red-black trees and what root should always be?
Answer: a) a color which is either red or black and root should always be black color only Explanation: 24) What is the disadvantage of using splay trees?
Answer: a) height of a splay tree can be linear when accessing elements in non-decreasing order Explanation: 25) Which of the following data structure can provide efficient searching of the elements?
Answer: d) 2-3 tree Explanation: 26) Consider the pseudo code: int avl(binarysearchtree root): if(not root) return 0 left....tree....height = avl(left....of....root) if(left....tree....height== -1) return left....tree....height right....tree....height= avl(right....of....root) if(right....tree....height==-1) return right....tree....height. Does the above code can check if a binary search tree is an AVL tree?
Answer: a) YES Explanation: 27) Given an empty AVL tree, how would you construct AVL tree when a set of numbers are given without performing any rotations?
Answer: b) find the median of the set of elements given, make it as root and construct the tree Explanation: 28) If several elements are competing for the same bucket in the hash table, what is it called?
Answer: c) Collision Explanation: 29) Which of the following is not the self balancing binary search tree?
Answer: d) None of the above Explanation: 30) What is the output of the following piece of code?
Answer: a) 3 and 5 Explanation: 31) What is the maximum height of any AVL-tree with 7 nodes? Assume that the height of a tree with a single node is 0.
Answer: b) 3 Explanation: 32) What output does the below pseudo code produces?
Answer: a) right rotation of subtree Explanation: 33) What can be the value of m in the division method?
Answer: a) Any prime number Explanation: 34) What does the following piece of code do?
Answer: c) Postorder traversal Explanation: 35) At what position the number 72 gets inserted in the following table? Index Key 0 22 1 34 2 3 4 5 56 6 7 18 8 41 9 10
Answer: d) 6 Explanation: 36) To restore the AVL property after inserting an element, we start at the insertion point and move towards root of that tree. is this statement true?
Answer: a) TRUE Explanation: 37) Why we need to a binary tree which is height balanced?
Answer: a) to avoid formation of skew trees Explanation: 38) What are the operations that could be performed in O(logn) time complexity by red-black tree?
Answer: a) insertion, deletion, finding predecessor, successor Explanation: 39) A dictionary is also called
Answer: d) All of the above Explanation: 40) Which one of the following hash functions on integers will distribute keys most uniformly over 10 buckets numbered 0 to 9 for i ranging from 0 to 2020?
Answer: b) h(i)=i*i*i mod 10 Explanation: Next Topic# |