Data Structures & AlgorithmsHardICPC regional · matching theory

Problem: What does the Gale-Shapley algorithm guarantee for stable matching with n men and n women?

  1. A. A maximum-weight matching is always found
  2. B. A stable matching is found in O(n^2) proposals
  3. C. Every man gets his first choice
  4. D. It runs in O(n log n) always

Correct answer: B. A stable matching is found in O(n^2) proposals

Each man proposes at most once to each woman, so at most n^2 proposals occur and the result is stable.

More Coding Interview Problems questions

Exams that ask this topic