GATE Computer ScienceHardGATE CS (PYQ pattern)
Twenty keys are hashed into a chained table with 8 slots, each key independently and uniformly. What are the expected number of colliding pairs (unordered pairs of keys landing in the same slot) and the expected number of empty slots?
- A. 23.75 and about 0.55
- B. 25.00 and about 0.55
- C. 23.75 and about 5.50
- D. 2.50 and about 0.55
Correct answer: A. 23.75 and about 0.55
Each of the C(20,2) = 190 pairs collides with probability 1/8, so by linearity the expected number of colliding pairs is 190/8 = 23.75. A given slot stays empty with probability (7/8)^20, so the expected number of empty slots is 8 * (7/8)^20 = 0.55. Using 20^2/2 pairs, or treating the load 2.5 as a count, are the usual slips.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- struct node { int d; struct node n; }; struct node f(struct node p, int k) { if (p == NULL) return NULL; struct node cur = p, prev = NULL…
- Keys 5, 3, 8, 3, 9, 1, 8, 5 are inserted one by one into an initially empty sorted singly linked list; each insertion scans from the head…
- Two sorted lists, X with 5 keys and Y with 7 keys (all 12 keys distinct), are merged with the standard two-pointer merge that stops…
- A singly linked list 10 -> 11 -> ... -> 19 is rearranged by a routine that places all nodes at odd positions (1st, 3rd, ...) first…
- A circular singly linked list holds nodes 1 to 100 in order. Deletion starts with node 1 itself and then removes every second remaining…
- struct T { int k; struct T l, r; }; int f(struct T n) { return n ? 1 + max(f(n->l), f(n->r)) : 0; } int g(struct T n) { return n ?…