Lecture 4 CSE 331 Sep 6, 2017
Lecture4
CSE331Sep6,2017
ReadthesyllabusCAREFULLY!NogradedmaterialwillbehandedbackIllyousubmitasignedform!
Sign-upforminiprojects
Email me your group (=3) composition
Deadline: Monday, Sep 25, 11:59pm
SeparateProofidea/proofdetails
TAofficehoursfinalized
MakeuprecitaIons
TODAY, 4-5pm in Davis 338A
Tomorrow, 5-6pm in Davis 113A
Onmatchings
Mal
Wash
Simon
Inara
Zoe
Kaylee
Avalidmatching
Mal
Wash
Simon
Inara
Zoe
Kaylee
Notamatching
Mal
Wash
Simon
Inara
Zoe
Kaylee
PerfectMatching
Mal
Wash
Simon
Inara
Zoe
Kaylee
Preferences
Mal
Wash
Simon
Inara
Zoe
Kaylee
Instability
Mal
Wash
Simon
Inara
Zoe
Kaylee
AstablemarriageEven
thoughBBTandJAarenotveryhappy
Twostablemarriages
StableMarriageproblem
SetofmenMandwomenW
Matching(nopolyandry/gamyinMXW)
PerfectMatching(everyonegetsmarried)
Instablity
m w
m� w�
Preferences(rankingofpotenIalspouses)
Stablematching=perfectmatching+noinstablity
MandWwithpreferences
StableMatching
QuesIons/Comments?
TwoQuesIons
Does a stable marriage always exist?
If one exists, how quickly can we compute one?
Today’slecture
Naïvealgorithm
Gale-ShapleyalgorithmforStableMarriageproblem
Thenaïvealgorithm
GothroughallpossibleperfectmatchingsS
IfSisastablematchingthenStop
Elsemovetothenextperfectmatching
n!matchings
Incrementalalgorithmtoproducealln!prefectmatchings?
Gale-ShapleyAlgorithm
DavidGale LloydShapley
O(n3)algorithm
Moralofthestory…
>
QuesIons/Comments?
Gale-ShapleyAlgorithmInIallyallmenandwomenarefree
Whilethereexistsafreewomanwhocanpropose
Letwbesuchawomanandmbethebestmanshehasnotproposedto
wproposestom
Ifmisfree
(m,w)getengaged
Else(m,w’)areengaged
Ifmprefersw’tow
wremainsfreeElse
(m,w)getengagedandw’isfree
Outputtheengagedpairsasthefinaloutput
Preferences
Mal
Wash
Simon
Inara
Zoe
Kaylee
GSalgorithm:FireflyEdiIon
1
1
2
2
3
3
4
4
5
5
6
6
Mal
Wash
Simon
Inara
Zoe
Kaylee
ObservaIon1InIallyallmenandwomenarefree
Whilethereexistsafreewomanwhocanpropose
Letwbesuchawomanandmbethebestmanshehasnotproposedto
wproposestom
Ifmisfree
(m,w)getengaged
Else(m,w’)areengaged
Ifmprefersw’tow
wremainsfreeElse
(m,w)getengagedandw’isfree
Outputtheengagedpairsasthefinaloutput
Onceamangetsengaged,heremainsengaged(to“bemer”
women)
ObservaIon2InIallyallmenandwomenarefree
Whilethereexistsafreewomanwhocanpropose
Letwbesuchawomanandmbethebestmanshehasnotproposedto
wproposestom
Ifmisfree
(m,w)getengaged
Else(m,w’)areengaged
Ifmprefersw’tow
wremainsfreeElse
(m,w)getengagedandw’isfree
Outputtheengagedpairsasthefinaloutput
Ifwproposestomaoerm’,thensheprefersm’
tom
QuesIons/Comments?
Whybotherprovingcorrectness?
Consider a variant where any free man or free woman can propose
Is this variant any different? Can you prove it?
GS’doesnotoutputastablemarriage