Lecture 3 CSE 331. Stable Matching Problem Problem Statement Algorithm Problem Definition Implementation Analysis.

Slides:



Advertisements
Similar presentations
Piyush Kumar (Lecture 3: Stable Marriage) Welcome to COT5405.
Advertisements

Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2013 Lecture 2.
Lecture 6 CSE 331 Sep 14. A run of the GS algorithm Mal Wash Simon Inara Zoe Kaylee.
CSE 421 Algorithms Richard Anderson Lecture 2. Announcements Office Hours –Richard Anderson, CSE 582 Monday, 10:00 – 11:00 Friday, 11:00 – 12:00 –Yiannis.
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.
Lecture 7 CSE 331 Sep 16, Feedback forms VOLUNTARY Last 5 mins of the lecture.
Lecture 10 CSE 331 Sep 22, Acceptable formats for blog posts Plain text LaTeX HTML.
Lecture 8 CSE 331 Sep 18, Homeworks Hand in your HW 1 HW 2 and solutions to HW 1 out at the end of class Not naming your collaborators is same as.
CSE 421 Algorithms Richard Anderson Lecture 3. Classroom Presenter Project Understand how to use Pen Computing to support classroom instruction Writing.
Lecture 9 CSE 331 Sep 21, Gale-Shapley Algorithm Intially all men and women are free While there exists a free woman who can propose Let w be such.
Lecture 8 CSE 331 Sep 17, HW 1 due today Place Q1 and Q2 in separate piles I will not accept HWs after 1:15pm.
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
1 Stable Matching Problem Goal. Given n men and n women, find a "suitable" matching. n Participants rate members of opposite sex. n Each man lists women.
Lecture 4 CSE 331 Sep 6, TA change Swapnoneel will leave us for 531 Jiun-Jie Wang will join us.
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.
Program Efficiency & Complexity Analysis. Algorithm Review An algorithm is a definite procedure for solving a problem in finite number of steps Algorithm.
CSE 331: Review. Main Steps in Algorithm Design Problem Statement Algorithm Real world problem Problem Definition Precise mathematical def “Implementation”
CSE 421 Algorithms Richard Anderson (for Anna Karlin) Winter 2006 Lecture 2.
The Stable Marriage Problem
Asymptotic Analysis CSE 331. Definition of Efficiency An algorithm is efficient if, when implemented, it runs quickly on real instances Implemented where?
CSE 331: Review.
CSCI 256 Data Structures and Algorithm Analysis Lecture 2 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.
CSE 421 Algorithms Richard Anderson Winter 2009 Lecture 4.
Analysis of Algorithms Spring 2016CS202 - Fundamentals of Computer Science II1.
CSE 331: Review August 1, Main Steps in Algorithm Design Problem Statement Algorithm Real world problem Problem Definition Precise mathematical.
Stable Matching.
Lecture 4 CSE 331 Sep 7, 2016.
Lecture 8 CSE 331 Sep 14, 2011.
Lecture 5 CSE 331 Sep 8, 2017.
Lecture 6 CSE 331 Sep 9, 2013.
CSE 421: Introduction to Algorithms
Lecture 5 CSE 331 Sep 10, 2010.
Lecture 7 CSE 331 Sep 15, 2010.
Lecture 4 CSE 331 Sep 6, 2017.
Lecture 7 CSE 331 Sep 14, 2016.
Lecture 6 CSE 331 Sep 11, 2017.
Lecture 6 CSE 331 Sep 13, 2010.
Lecture 9 CSE 331 Sep 20, 2010.
S. Raskhodnikova; based on slides by K. Wayne
Lecture 8 CSE 331 Sep 12, 2014.
Lecture 9 CSE 331 Sep 18, 2017.
Lecture 7 CSE 331 Sep 13, 2017.
Lecture 9 CSE 331 Sep 19, 2012.
CSE 421: Introduction to Algorithms
Richard Anderson Lecture 3
Lecture 5 CSE 331 Sep 6, 2013.
Lecture 5 CSE 331 Sep 7, 2012.
Lecture 8 CSE 331 Sep 16, 2016.
Lecture 7 CSE 331 Sep 13, 2011.
Lecture 9 CSE 331 Sep 19, 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.
Lecture 6 CSE 331 Sep 12, 2011.
Lecture 8 CSE 331 Sep 15, 2011.
Lecture 9 CSE 331 Sep 15, 2014.
Lecture 9 CSE 331 Sep 20, 2010.
Lecture 5 CSE 331 Sep 5, 2014.
Lecture 6 CSE 331 Sep 12, 2016.
Lecture 7 CSE 331 Sep 10, 2014.
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.
Lecture 11 CSE 331 Sep 20, 2013.
Presentation transcript:

Lecture 3 CSE 331

Stable Matching Problem Problem Statement Algorithm Problem Definition Implementation Analysis

Proof of Correctness: Gale-Shaply

Proof technique de jour Source: 4simpsons.wordpress.com Proof by contradiction Assume the negation of what you want to prove After some reasoning

CSE191 Flavor Prove there are infinitely many prime numbers Assume there are finitely many primes and call them P = {p 0, p 1, …, p n } Consider the number q = p 0 p 1… p n + 1 – The number q is not in P and is therefor composite – As such, q must be divisible by some p i in P However, q/p i has a remainder of 1 for all p i in P Therefore, q is prime which is a contradiction There must be infinitely many primes!

Now a CSE331 flavor proof by contradiction

GS algo outputs a stable matching Lemma 1: GS outputs a perfect matching S Lemma 2: S has no instability

Two obervations Obs 1: Once m is engaged he keeps getting engaged to “better” women Obs 2: If w proposes to m’ first and then to m (or never proposes to m) then she prefers m’ to m

Proof of Lemma 1 Lemma 1: GS outputs a perfect matching S Assume S is not a perfect matching There exists a woman w who is single The woman w must have proposed to all n men and they all rejected her or moved to a better woman Therefor, all n men are engaged (by observation 1) to the remaining n-1 women Contradiction since there is no polygamy in the algorithm

Proof of Lemma 2 By contradiction m m w w m’m’w’w’ Assume there is an instability (m,w’) m prefers w’ to w w’ prefers m to m’ w’ last proposed to m’

Contradiction by Case Analysis Depending on whether w’ had proposed to m or not Case 1: w’ never proposed to m w’w’ m w’ prefers m’ to m Assumed w’ prefers m to m’ Source: 4simpsons.wordpress.com By Obs 2

By Obs 1 Case 2: w’ had proposed to m Case 2.1: m had accepted w’ proposal m is finally engaged to w Thus, m prefers w to w’ 4simpsons.wordpress.com m w’w’ Case 2.2: m had rejected w’ proposal m was engaged to w’’ (prefers w’’ to w’) m is finally engaged to w (prefers w to w’’) m prefers w to w’ 4simpsons.wordpress.com By Obs 1

Overall structure of case analysis Did w’ propose to m? Did m accept w’ proposal? 4simpsons.wordpress.com

More formal proof in notes

Main Steps in Algorithm Design Problem Statement Algorithm Problem Definition Implementation Analysis n! Correctness Analysis And now: Runtime analysis

Definition of Efficiency An algorithm is efficient if, when implemented, it runs quickly on real instances Implemented where? Platform independent definition What are real instances? Worst-case Inputs Efficient in terms of what? Input size N N = 2n 2 for SMP

Definition-II n! Analytically better than brute force How much better? By a factor of 2?

Definition-III Should scale with input size If N increases by a constant factor, so should the measure Polynomial running time At most c. N d steps (c>0, d>0 absolute constants) Step: “primitive computational step”

Which one is better?

Now?

And now?

The actual run times n! 100n 2 n2n2 Asymptotic View

Asymptotic Analysis ( Travelling Salesman Problem

Asymptotic Notation O is similar to ≤ Ω is similar to ≥ Θ is similar to =

g(n) is O(f(n)) g(n) n0n0 c*f(n) for some c>0 n

g(n) is Ω(f(n)) g(n) n1n1 n ε*f(n) for some ε>0

Run time of an algorithm (Worst-case) run time T(n) for input size n Maximum number of steps taken by the algorithm for any input of size n

Gale-Shapley Algorithm Initially 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 free Else (m,w) get engaged and w’ is free Output the engaged pairs as the final output. These engaged pairs get married.

Implementation Steps How to represent the input? How do we find a free woman w? How would w pick her best unproposed man m? How do we know who m is engaged to? How do we decide if m prefers w’ to w?

Arrays and Linked Lists n numbers a 1,a 2,…,a n a1a1 a2a2 a3a3 anan n a1a1 a2a2 a3a3 anan Front Last ArrayLinked List Access ith elementO(1)O(i) Is e present?O(n)(O(log n) if sorted)O(n) Insert an elementO(n) O(1) given pointer Delete an elementO(n)O(1) given pointer Static vs DynamicStaticDynamic

Today’s first goal O(n 2 ) implementation of the Gale-Shapley algorithm More practice with run time analysis

Gale-Shapley Algorithm Initially 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 free Else (m,w) get engaged and w’ is free Output the engaged pairs as the final output. These engaged pairs get married. At most n 2 iterations O(1) time implementation

Puzzle Prove that any algorithm for the SMP takes Ω(n 2 ) time

Main Steps in Algorithm Design Problem Statement Algorithm Problem Definition “Implementation” Analysis n! Correctness Analysis