![Page 1: Lecture 6 CSE 331 Sep 10, 2012. Homeworks HW 1 posted online: see blog/piazza Pickup graded HW 0 in TA OHs](https://reader030.vdocuments.mx/reader030/viewer/2022032802/56649e0c5503460f94af571e/html5/thumbnails/1.jpg)
Lecture 6
CSE 331Sep 10, 2012
![Page 2: Lecture 6 CSE 331 Sep 10, 2012. Homeworks HW 1 posted online: see blog/piazza Pickup graded HW 0 in TA OHs](https://reader030.vdocuments.mx/reader030/viewer/2022032802/56649e0c5503460f94af571e/html5/thumbnails/2.jpg)
Homeworks
HW 1 posted online: see blog/piazza
Pickup graded HW 0 in TA OHs
![Page 3: Lecture 6 CSE 331 Sep 10, 2012. Homeworks HW 1 posted online: see blog/piazza Pickup graded HW 0 in TA OHs](https://reader030.vdocuments.mx/reader030/viewer/2022032802/56649e0c5503460f94af571e/html5/thumbnails/3.jpg)
Suggestions for Piazza
Email them: team “at” piazza “dot” com
![Page 4: Lecture 6 CSE 331 Sep 10, 2012. Homeworks HW 1 posted online: see blog/piazza Pickup graded HW 0 in TA OHs](https://reader030.vdocuments.mx/reader030/viewer/2022032802/56649e0c5503460f94af571e/html5/thumbnails/4.jpg)
Lecture pace
Mid-term
![Page 5: Lecture 6 CSE 331 Sep 10, 2012. Homeworks HW 1 posted online: see blog/piazza Pickup graded HW 0 in TA OHs](https://reader030.vdocuments.mx/reader030/viewer/2022032802/56649e0c5503460f94af571e/html5/thumbnails/5.jpg)
Online Office Hours
Tomorrow: 9:30pm to 10:30pm
![Page 6: Lecture 6 CSE 331 Sep 10, 2012. Homeworks HW 1 posted online: see blog/piazza Pickup graded HW 0 in TA OHs](https://reader030.vdocuments.mx/reader030/viewer/2022032802/56649e0c5503460f94af571e/html5/thumbnails/6.jpg)
Stable Marriage problem
Set of men M and women W
Matching (no polygamy in M X W)
Perfect Matching (everyone gets married)
Instablity
mm ww
m’ w’
Preferences (ranking of potential spouses)
Stable matching = perfect matching+ no instablity
![Page 7: Lecture 6 CSE 331 Sep 10, 2012. Homeworks HW 1 posted online: see blog/piazza Pickup graded HW 0 in TA OHs](https://reader030.vdocuments.mx/reader030/viewer/2022032802/56649e0c5503460f94af571e/html5/thumbnails/7.jpg)
Two Questions
Does a stable marriage always exist?
If one exists, how quickly can we compute one?
Answer both Qs in +ve by the Gale-
Shapley algorithm
Answer both Qs in +ve by the Gale-
Shapley algorithm
![Page 8: Lecture 6 CSE 331 Sep 10, 2012. Homeworks HW 1 posted online: see blog/piazza Pickup graded HW 0 in TA OHs](https://reader030.vdocuments.mx/reader030/viewer/2022032802/56649e0c5503460f94af571e/html5/thumbnails/8.jpg)
Gale-Shapley Algorithm
(er, not Nobel prize winners, at least not yet)
Women do all the proposing (different from the book)
Everyone is in one of three states: free, engaged and married
Step 1: A free woman w proposes to her most preferred man m. (m,w) get engaged
General step: A free woman w proposes to her top unproposed man m.
![Page 9: Lecture 6 CSE 331 Sep 10, 2012. Homeworks HW 1 posted online: see blog/piazza Pickup graded HW 0 in TA OHs](https://reader030.vdocuments.mx/reader030/viewer/2022032802/56649e0c5503460f94af571e/html5/thumbnails/9.jpg)
Questions/Comments?
![Page 10: Lecture 6 CSE 331 Sep 10, 2012. Homeworks HW 1 posted online: see blog/piazza Pickup graded HW 0 in TA OHs](https://reader030.vdocuments.mx/reader030/viewer/2022032802/56649e0c5503460f94af571e/html5/thumbnails/10.jpg)
Gale-Shapley AlgorithmIntially 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 freeElse
(m,w) get engaged and w’ is free
Output the engaged pairs as the final output
![Page 11: Lecture 6 CSE 331 Sep 10, 2012. Homeworks HW 1 posted online: see blog/piazza Pickup graded HW 0 in TA OHs](https://reader030.vdocuments.mx/reader030/viewer/2022032802/56649e0c5503460f94af571e/html5/thumbnails/11.jpg)
Preferences
Mal
Wash
Simon
Inara
Zoe
Kaylee
![Page 12: Lecture 6 CSE 331 Sep 10, 2012. Homeworks HW 1 posted online: see blog/piazza Pickup graded HW 0 in TA OHs](https://reader030.vdocuments.mx/reader030/viewer/2022032802/56649e0c5503460f94af571e/html5/thumbnails/12.jpg)
GS algorithm: Firefly Edition
1
1
2
2
3
3
4
4
5
5
6
6
Mal
Wash
Simon
Inara
Zoe
Kaylee