Skip to content

Instantly share code, notes, and snippets.

@kartikkukreja
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save kartikkukreja/0167ca90ee90e359642e to your computer and use it in GitHub Desktop.

Select an option

Save kartikkukreja/0167ca90ee90e359642e to your computer and use it in GitHub Desktop.
Stable Marriage Problem
Initially all m ∈ M and w ∈ W are free
while ∃ m who is free and hasn't proposed to every woman:
choose m
Let w be the highest-ranked woman in m's preference list to whom m has not yet proposed
if w is free:
(m, w) become engaged
elif w is currently engaged to m':
if w prefers m' to m:
m remains free
else w prefers m to m':
(m, w) become engaged
m' becomes free
return the set S of engaged pairs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment