Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof...

30
Lecture 4 CSE 331 Sep 6, 2017

Transcript of Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof...

Page 1: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

Lecture4

CSE331Sep6,2017

Page 2: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

ReadthesyllabusCAREFULLY!NogradedmaterialwillbehandedbackIllyousubmitasignedform!

Page 3: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

Sign-upforminiprojects

Email me your group (=3) composition

Deadline: Monday, Sep 25, 11:59pm

Page 4: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

SeparateProofidea/proofdetails

Page 5: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

TAofficehoursfinalized

Page 6: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

MakeuprecitaIons

TODAY, 4-5pm in Davis 338A

Tomorrow, 5-6pm in Davis 113A

Page 7: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

Onmatchings

Mal

Wash

Simon

Inara

Zoe

Kaylee

Page 8: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

Avalidmatching

Mal

Wash

Simon

Inara

Zoe

Kaylee

Page 9: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

Notamatching

Mal

Wash

Simon

Inara

Zoe

Kaylee

Page 10: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

PerfectMatching

Mal

Wash

Simon

Inara

Zoe

Kaylee

Page 11: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

Preferences

Mal

Wash

Simon

Inara

Zoe

Kaylee

Page 12: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

Instability

Mal

Wash

Simon

Inara

Zoe

Kaylee

Page 13: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

AstablemarriageEven

thoughBBTandJAarenotveryhappy

Page 14: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

Twostablemarriages

Page 15: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

StableMarriageproblem

SetofmenMandwomenW

Matching(nopolyandry/gamyinMXW)

PerfectMatching(everyonegetsmarried)

Instablity

m w

m� w�

Preferences(rankingofpotenIalspouses)

Stablematching=perfectmatching+noinstablity

MandWwithpreferences

StableMatching

Page 16: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

QuesIons/Comments?

Page 17: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

TwoQuesIons

Does a stable marriage always exist?

If one exists, how quickly can we compute one?

Page 18: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

Today’slecture

Naïvealgorithm

Gale-ShapleyalgorithmforStableMarriageproblem

Page 19: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

Thenaïvealgorithm

GothroughallpossibleperfectmatchingsS

IfSisastablematchingthenStop

Elsemovetothenextperfectmatching

n!matchings

Incrementalalgorithmtoproducealln!prefectmatchings?

Page 20: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

Gale-ShapleyAlgorithm

DavidGale LloydShapley

O(n3)algorithm

Page 21: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

Moralofthestory…

>

Page 22: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

QuesIons/Comments?

Page 23: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

Gale-ShapleyAlgorithmInIallyallmenandwomenarefree

Whilethereexistsafreewomanwhocanpropose

Letwbesuchawomanandmbethebestmanshehasnotproposedto

wproposestom

Ifmisfree

(m,w)getengaged

Else(m,w’)areengaged

Ifmprefersw’tow

wremainsfreeElse

(m,w)getengagedandw’isfree

Outputtheengagedpairsasthefinaloutput

Page 24: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

Preferences

Mal

Wash

Simon

Inara

Zoe

Kaylee

Page 25: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

GSalgorithm:FireflyEdiIon

1

1

2

2

3

3

4

4

5

5

6

6

Mal

Wash

Simon

Inara

Zoe

Kaylee

Page 26: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

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)

Page 27: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

ObservaIon2InIallyallmenandwomenarefree

Whilethereexistsafreewomanwhocanpropose

Letwbesuchawomanandmbethebestmanshehasnotproposedto

wproposestom

Ifmisfree

(m,w)getengaged

Else(m,w’)areengaged

Ifmprefersw’tow

wremainsfreeElse

(m,w)getengagedandw’isfree

Outputtheengagedpairsasthefinaloutput

Ifwproposestomaoerm’,thensheprefersm’

tom

Page 28: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

QuesIons/Comments?

Page 29: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

Whybotherprovingcorrectness?

Consider a variant where any free man or free woman can propose

Is this variant any different? Can you prove it?

Page 30: Lecture 4 - University at Buffaloatri/cse331/fall17/lectures/lect4.pdf · Separate Proof idea/proof details TA office hours finalized Makeup recitaIons TODAY, 4-5pm in Davis 338A

GS’doesnotoutputastablemarriage