CSE 143 Homework 3 (Stable Marriage)

Slides:



Advertisements
Similar presentations
1 Stable Matching A Special Case of Stable Marriage.
Advertisements

Piyush Kumar (Lecture 3: Stable Marriage) Welcome to COT5405.
slides created by Marty Stepp
Lecture 4 CSE 331 Sep 9, Blog posts for lectures Starts from today See Sep 8 post on the blog.
Lecture 5 CSE 331 Sep 11, HW 1 out today Will be handed out at the END of the lecture Read the homework policy document carefully START EARLY! ©ehow.com.
CSE 143 Lecture 19 Binary Search Trees read 17.3 slides created by Marty Stepp
CEG 221 Lesson 7: Algorithm Development From Start to Finish Mr. David Lippa.
Lecture 6 CSE 331 Sep 10, Homeworks HW 1 posted online: see blog/piazza Pickup graded HW 0 in TA OHs.
The Stable Marriage Problem
Pelvic floor Specialised Constraints for Stable Matching Problems Contact details: 17 Lilybank Gardens Glasgow G12 8QQ The Problem.
Lecture 2 CSE 331. Day 1 Survey On UBlearns Day 1 Survey (talking points) Security MS PhD for research Building PC’s for 442 It’s ok to play games –
Lecture 5 CSE 331 Sep 11, Submit the form I’ll need confirmation in writing. No graded material will be handed back till I get this signed form.
1 Today’s Material Iterative Sorting Algorithms –Sorting - Definitions –Bubble Sort –Selection Sort –Insertion Sort.
Design & Co-design of Embedded Systems Final Project: “The Match Maker” Second Phase Oral Presentation Safa S. Mahmoodian.
Bipartite Matching. Unweighted Bipartite Matching.
CSE 143 Lecture 20 Binary Search Trees read 17.3 slides created by Marty Stepp
slides adapted from Marty Stepp and Hélène Martin
Matching Boys Girls A B C D E
Stable Matching.
Lower bound for the Stable Marriage Problem
Stable Marriage Problem
Lecture 4 CSE 331 Sep 7, 2016.
Introduction to the Design and Analysis of Algorithms
Chapter 10 Iterative Improvement
The Stable Marriage Problem
Apollo Weize Sun, Mar.10th, 2017.
Lecture 5 CSE 331 Sep 8, 2017.
Lecture 6 CSE 331 Sep 9, 2013.
CSE 421: Introduction to Algorithms
CSE 143 Lecture 9 References and Linked Nodes reading: 3.3; 16.1
Lecture 5 CSE 331 Sep 10, 2010.
Lecture 7 CSE 331 Sep 15, 2010.
Lecture 4 CSE 331 Sep 6, 2017.
Lecture 6 CSE 331 Sep 11, 2017.
Lecture 6 CSE 331 Sep 13, 2010.
S. Raskhodnikova; based on slides by K. Wayne
Lecture 4 CSE 331 Sep 8, 2010.
Lecture 9 CSE 331 Sep 19, 2012.
CSE 421: Introduction to Algorithms
Lecture 3 CSE 331 Sep 2, 2016.
Lecture 4 CSE 331 Sep 4, 2013.
slides created by Marty Stepp and Hélène Martin
Lecture 2 CSE 331 Sep 1, 2011.
Discrete Math for CS CMPSC 360 LECTURE 9 Last time: Strong induction
Suppose that an experiment finds that more women prefer Toyotas than men. If the p-value is 0.14, then: The results are wrong There is a 14% chance of.
Lecture 5 CSE 331 Sep 6, 2013.
Lecture 5 CSE 331 Sep 7, 2012.
Blah blah blah.
Chapter 1 Introduction: Some Representative Problems
Lecture 8 CSE 331 Sep 16, 2016.
Lecture 10 CSE 331 Sep 21, 2011.
Lecture 12 CSE 331 Sep 27, 2010.
Lecture 8 CSE 331 Sep 15, 2017.
Lecture 10 CSE 331 Sep 21, 2012.
Suggested self-checks: Section 7.11 #1-11
Lecture 8 CSE 331 Sep 15, 2011.
Lecture 9 CSE 331 Sep 15, 2014.
Lecture 5 CSE 331 Sep 5, 2014.
Lecture 6 CSE 331 Sep 12, 2016.
Lecture 7 CSE 331 Sep 10, 2014.
Stable Matchings.
slides created by Marty Stepp
Piyush Kumar (Lecture 3: Stable Marriage)
Lecture 5 CSE 331 Sep 9, 2011.
Lecture 9 CSE 331 Sep 19, 2011.
Lecture 7 CSE 331 Sep 11, 2013.
Lecture 5 CSE 331 Sep 9, 2016.
slides created by Marty Stepp
Binary Search Trees Based on slides by Marty Stepp & Alyssa Harding
Week 13 - Wednesday CS221.
Presentation transcript:

CSE 143 Homework 3 (Stable Marriage) slides created by Marty Stepp http://www.cs.washington.edu/143/

Person has a name, a reference to a fiancée, a reference to a Queue of names ordered by preference, and a reference to a Map of names to rankings Person Queue<String> front "Charlotte" "Carrie" "Miranda" "Samantha" back name = "George" fiancee = null preferences = rankings = Map<String, Integer> "Carrie" "Charlotte" "Miranda" "Samantha" 2 1 3 4 Note that "rankings" contains similar information to "preferences" but in a different format. Use either one depending on what you need. keys values

Set<Person> Your constructor is passed two Sets of Person objects Person Person name = "George" fiancee = null preferences = ... rankings = ... Set<Person> name = "Jerry" fiancee = null preferences = ... rankings = ... Person Person name = "Kramer" fiancee = null preferences = ... rankings = ... name = "Newman" fiancee = null preferences = ... rankings = ... men Person Person name = "Samantha" fiancee = null preferences = ... rankings = ... Set<Person> name = "Carrie" fiancee = null preferences = ... rankings = ... Person Person name = "Miranda" fiancee = null preferences = ... rankings = ... name = "Charlotte" fiancee = null preferences = ... rankings = ... women

Map<String, Person> Your MatchMaker should create a map from names to Persons Person Map<String, Person> name = "Jerry" fiancee = null preferences = ... rankings = ... "Jerry" "Miranda" "Kramer" ... Person name = "Miranda" fiancee = null preferences = ... rankings = ... keys values Person name = "Kramer" fiancee = null preferences = ... rankings = ... Creating a map makes it easy for you to instantly look up a person by name instead of having to search through the sets.

Gale-Shapley algorithm How do I know whether Miranda prefers Jerry or George? Get Miranda from your Map Get her rankings of George and Jerry from her Map The lower ranking is preferred Map<String, Person> Person name = "Miranda" fiancee = null preferences = ... rankings = "Jerry" "Miranda" "Kramer" ... Map<String, Integer> keys values "George" "Jerry" "Kramer" "Newman" 4 2 3 1 keys values

Some pseudocode Suppose you have a Person variable named p1 referring to the Person object representing George. How do you find out George's most preferred woman? Look at the front of p1's getPreferences queue. Suppose George's most preferred woman is currently Miranda, and that you have a Person variable named p2 referring to the Person object representing Miranda. How do we find out how well Miranda likes George? Look in p2's getRankings map. If you give this map a string (a name) as a key, it will give you an integer ranking as a value. That integer is Miranda's ranking for George (1=best, 4=worst). How do I get this Person variable p2 to find Miranda? Your map can help you find a Person object by name.