GATE Computer ScienceVery hardGATE CS (PYQ pattern)
Four men m0–m3 and four women w0–w3 have preference lists (best first) m0: w1 w0 w2 w3; m1: w0 w2 w1 w3; m2: w1 w3 w2 w0; m3: w0 w1 w3 w2; w0: m2 m0 m3 m1; w1: m0 m3 m2 m1; w2: m3 m1 m0 m2; w3: m1 m2 m0 m3. The Gale–Shapley algorithm (men propose, free men are processed in index order via a queue, rejected men rejoin the back of the queue) makes how many proposals in total?
- A. 4
- B. 6
- C. 8
- D. 13
Correct answer: B. 6
Proposals: m0 → w1 (accepted), m1 → w0 (accepted), m2 → w1 (rejected, w1 prefers m0), m3 → w0 (w0 prefers m3 to m1, so m1 is freed), m2 → w3 (accepted), m1 → w2 (accepted). That is 6 proposals; the worst case n² − n + 1 = 13 is not reached.
More Algorithms questions
- For n = 5 distinct keys, let M be the worst-case comparisons of top-down merge sort (split ⌈n/2⌉ + ⌊n/2⌋, merge stops when one side is…
- What is the minimum number of comparisons that guarantees finding the median (the third smallest) of 5 distinct elements in the worst case?
- A hash table with chaining has m = 50 slots and stores n = 200 keys; each key is equally likely to be in any slot (simple uniform…
- Twenty distinct keys are hashed independently and uniformly into 100 slots. What is the expected number of keys that share their slot with…
- The closed intervals [1,4], [2,6], [3,5], [7,10], [8,12], [9,11], [13,15], [5,8], [10,14], [0,2] are given. What is the minimum number of…
- From index 0 of the array [3, 1, 4, 1, 2, 1, 1, 5, 2, 1, 1, 3, 1, 2, 1] you may jump forward at most a[i] positions from index i. What is…