lecture 4 cse 331 sep 6, 2011. ta change swapnoneel will leave us for 531 jiun-jie wang will join us

26
Lecture 4 CSE 331 Sep 6, 2011

Upload: beverly-thornton

Post on 02-Jan-2016

214 views

Category:

Documents


1 download

TRANSCRIPT

Lecture 4

CSE 331Sep 6, 2011

TA change

Swapnoneel will leave us for 531

Jiun-Jie Wang will join us

Office Hours

Jesse: R 1-1:50pm

Jiun-Jie: T 1-1:50pm; W 2-2:50pm;

Atri: M, F 2-2:50pm

Bell232

Not all signed forms turned in

I’ll need confirmation in writing. No graded material will be handed back tillI get this signed form from you!

Email subscription is now enabled

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

A stable marriageEven

though BBT and JA are not very happy

Even though BBT and JA are not very happy

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

A puzzle (if you’re bored)

For any n, what is the maximum number of stable matchings (for the same problem instance)?

Prove as tight upper and lower bounds as you can.

If you’re still bored

Come talk to me if you’re interested in a research problem

If there is enough interest, I’ll work with up to two of you Use the last lecture for your research presentations

(Make some solid progress on the puzzle without google first though)

If you’re free this weekend

http://www.cse.buffalo.edu/events/theory-IV/

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

If S is a stable matchingthen Stop

Else move to the next perfect matching

n! matchings

Gale-Shapley Algorithm

David Gale Lloyd Shapley

O(n3) algorithmO(n3) algorithm

Moral of the story…

>

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

Preferences

Mal

Wash

Simon

Inara

Zoe

Kaylee

GS algorithm: Firefly Edition

1

1

2

2

3

3

4

4

5

5

6

6

Mal

Wash

Simon

Inara

Zoe

Kaylee