GaleShapleyAlgorithmus
The Gale-Shapley Algorithmus, often called the Gale–Shapley algorithm, is a solution to the stable marriage problem. It was introduced by David Gale and Lloyd Shapley in 1962 and provides a method for finding a stable matching between two equally sized sets of agents, typically referred to as men and women, based on their strict preference lists. The algorithm can be adapted to many-to-one settings such as hospitals and residents or colleges and applicants.
In its classic form, the procedure proceeds in rounds. Each unengaged proposer (for example, a man) applies
Two key properties are stability and optimality. A stable matching contains no blocking pairs. With strict
Complexity for the basic version is typically O(n^2) time and O(n^2) space for n pairs, though implementations