Sie sind auf Seite 1von 3

Course Introduction

• Instructor
CSE 421 – Richard Anderson,
anderson@cs.washington.edu
Algorithms • Teaching Assistant
– Yiannis Giotas, giotas@cs.washington.edu
Richard Anderson
Lecture 1

All of Computer Science is the


Mechanics
Study of Algorithms
• It’s on the web
• Weekly homework
• Midterm
• Final exam

• Subscribe to the mailing list

Text book How to study algorithms


• Algorithm Design • Zoology
• Jon Kleinberg, Eva Tardos • Mine is faster than yours is
• Algorithmic ideas
• Read Chapters 1 & 2 – Where algorithms apply
– What makes an algorithm work
– Algorithmic thinking

1
Introductory Problem:
Formal notions
Stable Matching
• Setting: • Perfect matching
– Assign TAs to Instructors • Ranked preference lists
– Avoid having TAs and Instructors wanting • Stability
changes
• E.g., Prof A. would rather have student X than her
m1 w1
current TA, and student X would rather work for
Prof A. than his current instructor.
m2 w2

Examples Examples
• m1: w1 w2 • m1: w1 w2 • m1: w1 w2
• m2: w2 w1 • m2: w1 w2 • m2: w2 w1
• w1: m1 m2 • w1: m1 m2 • w1: m2 m1
• w2: m2 m1 • w2: m1 m2 • w2: m1 m2

Intuitive Idea for an Algorithm Algorithm


• m proposes to w Initially all m in M and w in W are free
While there is a free m
– If w is unmatched, w accepts
w highest on m’s list that m has not proposed to
– If w is matched to m2 if w is free, then match (m, w)
• If w prefers m to m2, w accepts else
• If w prefers m2 to m, w rejects suppose (m2, w) is matched
if w prefers m to m2
unmatch (m2, w)
• Unmatched m proposes to highest w on its match (m, w)
preference list

2
Claim: The algorithms stops in at
Does this work?
most n2 steps
• Does it terminate? • Why?
• Is the result a stable matching?

• Begin by identifying invariants and


measures of progress
– m’s proposals get worse
– Once w is matched, w stays matched
– w’s partners get better

The algorithm terminates with a


The resulting matching is stable
perfect matching
• Why? • Suppose m1 w1
– m1 prefers w2 to w1
– w2 prefers m1 to m2 m2 w2

• How could this happen?

Das könnte Ihnen auch gefallen