Imagine you have two groups, each of size
Now, this is often told as a story. One group is male, the other is female, and everyone gets married, hence the name the Stable Marriage Problem. This problem is solved by the Gale-Shapley algorithm, which can be simply described as follows:
- All the men propose to their top choice of women.
- The women become tentatively engaged to their top choice of the men who have proposed to them.
- All rejected men propose to their next choice, and the women again select whichever man they prefer, possibly rejecting the one they were already engaged to.
This process continues until all individuals are paired, which means that this algorithm guarantees stable matching and also has a
{% method %} {% sample lang="jl" %} import, lang:"julia" {% sample lang="py" %} import, lang:"python" {% sample lang="hs" %} import, lang:"haskell" {% sample lang="c" %} import, lang:"c_cpp" {% sample lang="cpp" %} import, lang:"c_cpp" {% sample lang="js" %} import, lang:"javascript" {% sample lang="cs" %} GaleShapleyAlgorithm.cs import, lang:"csharp" Person.cs import, lang:"csharp" Program.cs import, lang:"csharp" ListExtensions.cs import, lang:"csharp" {% endmethod %}
<script> MathJax.Hub.Queue(["Typeset",MathJax.Hub]); </script>