Assignment 1 is out, due in February 15th
Will be going into more depth on the stable matching problem, and then on “math background”.
Suppose we have students $A,B,C$ and companies $X, Y, Z$, with their preferences as follows:
$A: X,Y,Z\quad B: X,Z,Y\quad C:Y,Z,X$
$X: B,A,C\quad Y:C,A,B\quad Z:A,B,C$
Is $(A,X), (B,Z), (C,Y)$ a stable matching?
No, $B$ and $X$ would rather defect to pair up with each other.
Initially, all companies and students are unengaged.
While there is a company C that is unengaged and hasn't made an offer
to every student:
Let S be the highest ranked student for C to whom C has not yet made
an offer.
If S is unengaged then
(C, S) become engaged.
Else
Let C' be the company that S is engaged to.
If S prefers C to C' then
(C, S) become engaged
C' becomes unengaged
endif
endif
endwhile
Output the set of engaged pairs
Lemma 1: Once a student receives an offer, she remains engaged until the end of the algorithm, and her job can only improve over time.
Proof: An unengaged student who receives an offer always becomes engaged.
An engaged student can only switch companies; they cannot become unengaged.
A student only switches to a company they prefer. $\square$
Lemma 2: As the algorithm proceeds, the sequence of students engaged to a given company can only decrease in preference over time.
Proof: Companies make offers in decreasing preference order.
Lemma 3: **If there are $n$ companies, then the algorithm will terminate after at most $n^2$ iterations of the while loop.
Proof: Let $P(t)$ be the set of pairs $(c, s)$ such that $c$ has made an offer to $s$ by the end of the $t$th iteration.