Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 12 CSE 331 Sep 27, 2010.

Similar presentations


Presentation on theme: "Lecture 12 CSE 331 Sep 27, 2010."— Presentation transcript:

1 Lecture 12 CSE 331 Sep 27, 2010

2 Feedback forms You will have last 5 minutes of the lecture
Completely voluntary You will have last 5 minutes of the lecture

3 Online Office Hour Wed 9:30-10:30

4 Gale-Shapley Algorithm
At most n2 iterations 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 O(1) time implementation 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

5 Gale-Shapley Algorithm
Linked list of free women Intially all men and women are free Array Next[w] 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 Today If m is free (m,w) get engaged Else (m,w’) are engaged Today If m prefers w’ to w w remains free ManPref[m,j] WomanPref[w,j] Else (m,w) get engaged and w’ is free Output the engaged pairs as the final output

6 Yes, Firefly again but with numbers
1 1 2 2 3 3

7 The data structures so far
1 2 3 Man-Pref 1 2 3 1 2 3 1 2 3 1 3 Linked list of free women 2 1 2 3 first 1 Next

8 Implementation Steps (i) How to represent the input?
(ii) How do we find a free woman w? Init: O(n), Update: O(1) (iii) How would w pick her best unproposed man m? Init: O(n), Update: O(1) (iv) How do we know who m is engaged to? (v) How do we decide if m prefers w’ to w?

9 Overall running time n2 X ( O(1) + O(1) + Update(iv) + Update(v) )
O(n) + O(n) + Init(iv) + Init(v) n2 X ( O(1) + O(1) + Update(iv) + Update(v) )

10 Questions?

11 Reading Assignments Sec 1.1 and Chap. 2 in [KT]

12 Relationship: Mention in other’s program
Graphs Representation of relationships between pairs of entities/elements Edge Entities: News hosts Relationship: Mention in other’s program Vertex

13 Graphs are omnipresent
Airline Route maps

14 What does this graph represent?
Internet

15 And this one? Math articles on Wikipedia

16 And this one?

17 Rest of today’s agenda Basic Graph definitions


Download ppt "Lecture 12 CSE 331 Sep 27, 2010."

Similar presentations


Ads by Google