# cse 421 algorithms

Post on 01-Jan-2016

26 views

Category:

## Documents

Tags:

• #### lower wrankclaim

Embed Size (px)

DESCRIPTION

CSE 421 Algorithms. Richard Anderson Winter 2009 Lecture 1. CSE 421 Course Introduction. CSE 421, Introduction to Algorithms MWF, 1:30-2:20 pm EEB 037 Instructor Richard Anderson, anderson@cs.washington.edu Office hours: CSE 582 Monday, 3:00-3:50 pm, Thursday, 11:00-11:50 am - PowerPoint PPT Presentation

TRANSCRIPT

• CSE 421AlgorithmsRichard Anderson Winter 2009Lecture 1

• CSE 421 Course IntroductionCSE 421, Introduction to AlgorithmsMWF, 1:30-2:20 pmEEB 037InstructorRichard Anderson, anderson@cs.washington.eduOffice hours: CSE 582Monday, 3:00-3:50 pm, Thursday, 11:00-11:50 amTeaching Assistant Aeron Bryce, paradoxa@cs.washington.eduOffice hours: CSE 216Monday, 12:30-1:20 pm, Tuesday, 12:30-1:20 pm

• AnnouncementsIts on the web.Homework due WednesdaysHW 1, Due January 14, 2009Its on the web (or will be soon)Subscribe to the mailing list

• Text bookAlgorithm DesignJon Kleinberg, Eva Tardos

Expected coverage:Chapter 1 through 7

• Course MechanicsHomeworkDue WednesdaysAbout 5 problems + E.C.Target: 1 week turnaround on gradingExams (In class)Midterm, Monday, Feb 9 (probably)Final, Monday, March 16, 2:30-4:20 pmApproximate grade weightingHW: 50, MT: 15, Final: 35Course webSlides, Handouts, Recorded Lectures from 2006

• All of Computer Science is the Study of Algorithms

• How to study algorithmsZoologyMine is faster than yours isAlgorithmic ideasWhere algorithms applyWhat makes an algorithm workAlgorithmic thinking

• Introductory Problem:Stable MatchingSetting:Assign TAs to InstructorsAvoid having TAs and Instructors wanting changesE.g., Prof A. would rather have student X than her current TA, and student X would rather work for Prof A. than his current instructor.Purpose of the example: new, interesting problem, show how different ideas apply

• Formal notionsPerfect matchingRanked preference listsStability

m1w1m2w2

• Example (1 of 3)m1: w1 w2m2: w2 w1w1: m1 m2w2: m2 m1m1m2w2w1

• Example (2 of 3)m1: w1 w2m2: w1 w2w1: m1 m2w2: m1 m2m1m2w2w1

• Example (3 of 3)m1: w1 w2m2: w2 w1w1: m2 m1w2: m1 m2m1m2w2w1

• Formal ProblemInputPreference lists for m1, m2, , mnPreference lists for w1, w2, , wnOutputPerfect matching M satisfying stability property:If (m, w) M and (m, w) M then(m prefers w to w) or (w prefers m to m) m, w, (m, w) is NOT an instability

• Idea for an Algorithmm proposes to wIf w is unmatched, w acceptsIf w is matched to m2If w prefers m to m2w accepts m, dumping m2If w prefers m2 to m, w rejects m

Unmatched m proposes to the highest w on its preference list that it has not already proposed to

• AlgorithmInitially all m in M and w in W are freeWhile there is a free mw highest on ms list that m has not proposed toif w is free, then match (m, w)else suppose (m2, w) is matchedif w prefers m to m2unmatch (m2, w)match (m, w)

• Examplem1: w1 w2 w3m2: w1 w3 w2m3: w1 w2 w3

w1: m2 m3 m1w2: m3 m1 m2w3: m3 m1 m2

m1m2w2w1m3w3Order: m1, m2, m3, m1, m3, m1

• Does this work?Does it terminate?Is the result a stable matching?

Begin by identifying invariants and measures of progressms proposals get worse (have higher m-rank)Once w is matched, w stays matchedws partners get better (have lower w-rank)

• Claim: The algorithm stops in at most n2 stepsEach m asks each w at most once

• When the algorithms halts, every w is matchedWhy?

Hence, the algorithm finds a perfect matchingInvariant: partial matchingWhat happens when some m reaches its last choice?exactly n-1 ws much be matchedlast choice must be available

• The resulting matching is stableSuppose (m1, w1) M, (m2, w2) Mm1 prefers w2 to w1

How could this happen?m1w1m2w2m1 proposed to w2 before w1w2 rejected m1 for m3w2 prefers m3 to m1w2 prefers m2 to m3

• ResultSimple, O(n2) algorithm to compute a stable matchingCorollaryA stable matching always exists

• A closer lookStable matchings are not necessarily fairm1: w1 w2 w3m2: w2 w3 w1m3: w3 w1 w2

w1: m2 m3 m1w2: m3 m1 m2w3: m1 m2 m3m1m2m3w1w2w3How many stable matchings can you find?

• Algorithm under specifiedMany different ways of picking ms to proposeSurprising resultAll orderings of picking free ms give the same result

Proving this type of resultReordering argumentProve algorithm is computing something mores specificShow property of the solution so it computes a specific stable matching

• Proposal Algorithm finds the best possible solution for MFormalize the notion of best possible solution:(m, w) is valid if (m, w) is in some stable matchingbest(m): the highest ranked w for m such that (m, w) is validS* = {(m, best(m)}Every execution of the proposal algorithm computes S*

• ProofSee the text book pages 9 12

Related result: Proposal algorithm is the worst case for WAlgorithm is the M-optimal algorithmProposal algorithms where ws propose is W-Optimal

• Best choices for one side may be bad for the otherDesign a configuration for problem of size 4:M proposal algorithm:All ms get first choice, all ws get last choiceW proposal algorithm:All ws get first choice, all ms get last choicem1:

m2:

m3:

m4:

w1:

w2:

w3:

w4:

Ms:1342234131244123

Ws:2341134241233124

• But there is a stable second choiceDesign a configuration for problem of size 4:M proposal algorithm:All ms get first choice, all ws get last choiceW proposal algorithm:All ws get first choice, all ms get last choiceThere is a stable matching where everyone gets their second choicem1:

m2:

m3:

m4:

w1:

w2:

w3:

w4:

Ms:1342243132144123

Ws:2431134241233214

• Key ideasFormalizing real world problemModel: graph and preference listsMechanism: stability conditionSpecification of algorithm with a natural operationProposalEstablishing termination of process through invariants and progress measureUnder specification of algorithmEstablishing uniqueness of solution

****************************

Recommended