GATE Computer ScienceHardGATE CSE
Twelve keys 15, 22, 5, 31, 10, 27, 12, 40, 3, 18, 20, 25 are inserted in this order into a hash table of 5 slots with separate chaining, h(k) = k mod 5, and each new key is inserted at the head of its chain. Counting one comparison per key examined, what is the average number of comparisons for a successful search over these 12 keys?
- A. 33/12
- B. 31/12
- C. 28/12
- D. 37/12
Correct answer: B. 31/12
Chains (head first): 0: 25,20,40,10,5,15; 1: 31; 2: 12,27,22; 3: 18,3; 4: . Total comparisons 31 over 12 keys, so the average is 31/12 ≈ 2.58.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- Keys 40, 20, 60, 10, 30, 50, 70, 25, 35, 45, 65 are inserted into an empty BST. The root 40 is then deleted, replacing it by its inorder…
- Integers 1, 2, 3, 4, 5, 6 are pushed onto a stack in this order, with pops allowed at any time. How many distinct complete output…
- A binary tree has preorder 8 3 1 6 4 7 10 14 13 and inorder 1 3 4 6 7 8 10 13 14. What is its postorder traversal?
- int c = 0; for (int i = 1; i < 100; i = 2) for (int j = 0; j < i; j++) c++; What is the final value of c?
- void f(int a[], int n) { a[0] = n; n = a[1]; a = a + 1; a[0] = 99; } int main() { int x[3] = {1, 2, 3}; int m = 5; f(x, m); printf("%d %d…
- How many structurally distinct binary search trees on 6 keys have height exactly 3, where height is the number of edges on the longest…