Image: Mike Weber, CC BY-SA 2.0The 1962 algorithm that assigns doctors and school places
Every year in March about forty thousand young doctors in the United States learn, at the same moment, which hospital will train them. No money changes hands and no hospital makes an offer. Each applicant submits a ranked list of programmes, each programme submits a ranked list of applicants, and a computer runs an algorithm whose core was published in 1962 in the American Mathematical Monthly by David Gale and Lloyd Shapley, under the title "College Admissions and the Stability of Marriage". The paper is seven pages long, uses no mathematics beyond counting, and proves two things that a market with prices cannot promise.
What stable means
Take three applicants, call them \(a_1, a_2, a_3\), and three hospitals \(h_1, h_2, h_3\), each with one place. Everybody ranks everybody on the other side. A matching assigns each applicant to one hospital. It is unstable if there is an applicant and a hospital who are not matched to each other and who would both prefer to be: she ranks that hospital above the one she got, and it ranks her above the applicant it got. Such a pair is called a blocking pair, because the two of them can get together and wreck the assignment. A matching with no blocking pair is stable.
Gale and Shapley asked whether a stable matching always exists, whatever the preference lists, and showed that it does by giving a procedure that finds one. The procedure is now called deferred acceptance, and here it is with applicants proposing.
In the first round every applicant proposes to the hospital at the top of her list. Each hospital looks at the proposals it received, holds the one it ranks highest, and rejects the others. Holding is not accepting; that is the deferral in the name. In the second round every rejected applicant proposes to the next hospital on her list, and each hospital again compares all proposals in hand, including the one it was holding, keeps the best, and rejects the rest. The rounds continue until no applicant is rejected, which must happen because nobody proposes twice to the same hospital. Then every hospital accepts the proposal it is holding.
Why the result is stable
Suppose the procedure ends and some applicant \(a\) prefers hospital \(h\) to the hospital she got. Then she proposed to \(h\) at some round, since she went down her list in order and got past it. Hospital \(h\) rejected her, either at once or later, and it only ever rejects a proposal in favour of one it ranks higher. Hospitals only trade up, so the applicant \(h\) ended with is ranked above \(a\). The pair \(a\) and \(h\) therefore does not block. Since \(a\) and \(h\) were arbitrary, no pair blocks, and the matching is stable. That is the whole proof.
The paper's second result is less obvious. There can be several stable matchings, and the one found by the applicant-proposing procedure is the best stable matching for every applicant at once: no applicant does better in any other stable matching. The hospital-proposing version gives the hospital-optimal one, which is the applicant-pessimal one. Whoever proposes gains. Later work added a third fact, proved by Lester Dubins and David Freedman in 1981 and by Alvin Roth in 1982: in the applicant-proposing procedure no applicant can get a better hospital by submitting a false list. Truthful ranking is a dominant strategy for the proposing side. For the other side it is not, and no procedure that always produces a stable matching can be truthful for both sides.
The doctors
The National Resident Matching Program began in 1952, ten years before the paper, because American hospitals had been making offers to medical students earlier and earlier, at one point two years before graduation, in a scramble that served nobody. The clearing house that replaced the scramble used an algorithm that its designers had worked out by hand. In 1984 Roth showed that this algorithm was deferred acceptance with hospitals proposing, which explained why the match had survived for three decades while clearing houses elsewhere with unstable algorithms had collapsed: participants had no reason to go round it. Between 1995 and 1998 Roth and Elliott Peranson redesigned the system for the NRMP. It has run with applicants proposing since 1998, with extensions to handle couples who want two positions in the same city, which is what makes the real problem harder than the paper's.
The scale is worth stating. In the 2025 Main Residency Match, announced on 21 March 2025, 47,208 applicants submitted rank order lists for 43,237 positions, and 94.3 per cent of the positions were filled by the algorithm. The NRMP publishes its data every year, down to how many programmes applicants ranked.
The schools
The same idea assigns pupils to secondary schools in New York City, since 2003, and in Boston, since 2005, after Atila Abdulkadiroğlu and Tayfun Sönmez showed in 2003 that school choice is a matching problem with the schools' priorities in place of preferences. Boston's old rule had been to give each school first to the pupils who ranked it first, then to those who ranked it second, and so on. That sounds fair and is a trap: a pupil who ranks a popular school first and misses it finds her second choice already full of pupils who ranked it first, so families learned to rank strategically, and the ones who did not were hurt. Under deferred acceptance a family can rank schools in its true order of preference, which was the main argument for the change.
Gale died in 2008. Shapley shared the 2012 Nobel prize in economic sciences with Roth, the citation naming the theory of stable allocations and the practice of market design. The seven pages of 1962 are a good example of what a theorem in game theory can look like: no equations to speak of, a definition that captures what matters about a market, an algorithm, and a proof short enough to hold in one's head.
Unit 15 of the Game Theory Masterclass runs deferred acceptance both ways on a three-by-three example, shows the hospital that profits from lying and the applicant who cannot, works the Boston mechanism against it, and then turns to the market where the same ideas are used without any money at all: the exchange of kidneys between incompatible donor pairs.


