Lecture 5 CSE 331 Sep 7, 2012
Not all signed forms turned in I’ll need confirmation in writing. No graded material will be handed back till I get this signed form from you!
Sign-up for mini projects Send in THREE choices for dates
Homeworks HW 1 posted online: see blog/piazza Pickup graded HW 0 in TA OHs
On matchings Mal Wash Simon Inara Zoe Kaylee
A valid matching Mal Wash Simon Inara Zoe Kaylee
Not a matching Mal Wash Simon Inara Zoe Kaylee
Perfect Matching Mal Wash Simon Inara Zoe Kaylee
Preferences Mal Wash Simon Inara Zoe Kaylee
Instability Mal Wash Simon Inara Zoe Kaylee
Even though BBT and JA are not very happy A stable marriage Even though BBT and JA are not very happy
Two stable marriages
Stable Marriage problem Input: M and W with preferences Output: Stable Matching Set of men M and women W Preferences (ranking of potential spouses) Matching (no polygamy in M X W) Perfect Matching (everyone gets married) m w m’ w’ Instablity Stable matching = perfect matching+ no instablity
Questions/Comments?
Two Questions Does a stable marriage always exist? If one exists, how quickly can we compute one?
Today’s lecture Naïve algorithm Gale-Shapley algorithm for Stable Marriage problem
Discuss: Naïve algorithm!
The naïve algorithm Go through all possible perfect matchings S n! matchings If S is a stable matching then Stop Else move to the next perfect matching
Gale-Shapley Algorithm David Gale Lloyd Shapley O(n3) algorithm
Moral of the story… >
Questions/Comments?
Gale-Shapley Algorithm Intially all men and women are free While there exists a free woman who can propose Let w be such a woman and m be the best man she has not proposed to w proposes to m If m is free (m,w) get engaged Else (m,w’) are engaged If m prefers w’ to w w remains free Else (m,w) get engaged and w’ is free Output the engaged pairs as the final output
Preferences Mal Wash Simon Inara Zoe Kaylee
GS algorithm: Firefly Edition Mal Inara 1 2 3 4 5 6 Wash Zoe 1 Simon Kaylee