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?

  1. A. 4
  2. B. 6
  3. C. 8
  4. 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

Exams that ask this topic