GATE Computer ScienceVery hardGATE CSE
A hash table with 7 buckets uses separate chaining, h(k) = k mod 7, and every new key is inserted at the head of its chain. The keys 50, 700, 76, 85, 92, 73, 101, 14, 28, 35, 21, 49, 63 are inserted in that order. If every key is then searched once, how many key comparisons are made in total (a successful search counts the comparison with the found key)?
- A. 41
- B. 34
- C. 47
- D. 38
Correct answer: D. 38
Chains (head first): [63,49,21,35,28,14,700] [92,85,50] [] [101,73] [] [] [76]; the position of each key in its chain sums to 38.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- A hash table of size 13 uses double hashing: the i-th probe for key k is (k mod 13 + i·(1 + k mod 11)) mod 13. The keys 18, 41, 22, 44…
- Keys 40, 20, 60, 10, 30, 50, 70, 5, 15, 25, 35, 45, 55, 65, 80, 3, 12, 23, 27, 90 are inserted into an empty BST. How many nodes have a…
- In a knockout (tournament-tree) method, what is the minimum number of comparisons needed in the worst case to find both the smallest and…
- A binary heap stored in A[1..200] has the usual shape (complete binary tree, children of i at 2i and 2i+1). Taking the height of a leaf as…
- int f(int n) { if (n == 0) return 0; return (n & 1) + f(n >> 1) + f(n >> 2); } What does f(100) return?
- Assume sizeof(int) = 4 and sizeof(int ) = sizeof(int ()[4]) = 8. int a[3][4]; / a[i][j] = 4i + j / int (r)[4] = a + 1; int p = (r + 1) +…