GATE Computer ScienceVery hardGATE CS (PYQ pattern)
Men m0–m3 and women w0–w3 have the preference lists (best first) m0: w2 w0 w1 w3; m1: w0 w1 w3 w2; m2: w1 w2 w0 w3; m3: w2 w3 w1 w0; w0: m1 m3 m0 m2; w1: m2 m1 m3 m0; w2: m3 m0 m2 m1; w3: m0 m2 m1 m3. In the man-optimal stable matching produced by men-proposing Gale–Shapley, who is m0's partner?
- A. w0
- B. w3
- C. w1
- D. w2
Correct answer: B. w3
m0 proposes to w2 but w2 prefers m3; m3's first choice is also w2 and wins her. Following the rejections gives the matching m0–w3, m1–w0, m2–w1, m3–w2. m0 ends with his last choice because every better woman prefers someone else.
More Algorithms questions
- Union by rank without path compression is performed (ties: the root of the second argument is attached below the root of the first) on…
- Graham scan or Andrew's monotone chain is used on the points (0,0), (4,1), (2,2), (6,3), (3,5), (8,6), (5,7), (1,8), (7,3), (4,4), (2,6)…
- A Fenwick tree (binary indexed tree) over positions 1–100 performs update(i) by visiting i, then i + (i & −i), and so on while the index…
- The Z-array of a string s has Z[i] = length of the longest common prefix of s and s[i..]. (Z[0] is taken as 0.) What is the sum of all Z…
- What is the length of the longest palindromic substring (contiguous) of xabcbaxyzzyxabcdcbay?
- Consider the congruence 46x ≡ 18 (mod 240). How many solutions x does it have in 0…239, and what is the smallest one?