Download presentation
Presentation is loading. Please wait.
Published byLesley Wilkinson Modified over 9 years ago
1
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 1
2
Course Overview Class webpage: http://www.stfx.ca/people/igondra/csci256
3
Algorithm –[webster.com] A procedure for solving a mathematical problem (as of finding the greatest common divisor) in a finite number of steps that frequently involves repetition of an operation –[Knuth, TAOCP] An algorithm is a finite, definite, effective procedure, with some input and some output Algorithms Great algorithms are the poetry of computation. Just like verse, they can be terse, allusive, dense, and even mysterious. But once unlocked, they cast a brilliant new light on some aspect of computing. - Francis Sullivan
4
Theory of Algorithms "As soon as an Analytic Engine exists, it will necessarily guide the future course of the science. Whenever any result is sought by its aid, the question will arise - By what course of calculation can these results be arrived at by the machine in the shortest time? - Charles Babbage
5
Theory of Algorithms Claim: All of Computer Science is the study of algorithms What is expertise? How do experts differ from novices?
6
Algorithmic Paradigms Design and analysis of computer algorithms –Greed –Divide-and-conquer –Dynamic programming –Network flow –Intractability –Coping with intractability
7
What is a Problem? Instance Solution Constraints on solution Measure of value
8
A First Problem: Stable Matching Setting: –Assign TAs to Instructors –Avoid having TAs and Instructors wanting changes E.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
9
Stable Matching Problem Goal: Given n men and n women, find a "suitable" matching –Each man lists women in order of preference from best to worst –Each woman lists men in order of preference from best to worst ZeusAmy Clare Bertha Yancey Bertha Clare Amy XavierAmy Clare Bertha 1 st 2 nd 3 rd Men’s Preference Profile favoriteleast favorite ClareXavierZeusYancey BerthaXavierZeusYancey AmyYanceyZeusXavier 1 st 2 nd 3 rd Women’s Preference Profile favoriteleast favorite
10
Stable Matching Problem Perfect matching: everyone is matched monogamously –Each man gets exactly one woman –Each woman gets exactly one man Stability: no incentive for some pair of participants to undermine assignment by joint action –In matching M, an unmatched pair m-w is unstable if man m and woman w prefer each other to current partners
11
Stable Matching Problem Stable matching: perfect matching with no unstable pairs Stable matching problem: Given the preference lists of n men and n women, find a stable matching if one exists
12
Stable Matching Problem Q: Is assignment X-C, Y-B, Z-A stable? ZeusAmyClareBertha YanceyBerthaClareAmy XavierAmyClareBertha 1 st 2 nd 3 rd Men’s Preference Profile ClareXavierZeusYancey BerthaXavierZeusYancey AmyYanceyZeusXavier 1 st 2 nd 3 rd Women’s Preference Profile favoriteleast favoritefavorite least favorite
13
Stable Matching Problem Q: Is assignment X-C, Y-B, Z-A stable? A: No. Bertha and Xavier will hook up ZeusAmyClareBertha YanceyBerthaClareAmy XavierAmyClareBertha 1 st 2 nd 3 rd Men’s Preference Profile ClareXavierZeusYancey BerthaXavierZeusYancey AmyYanceyZeusXavier 1 st 2 nd 3 rd Women’s Preference Profile favoriteleast favoritefavorite least favorite
14
Stable Matching Problem Q: Is assignment X-A, Y-B, Z-C stable? A: Yes ZeusAmyClareBertha YanceyBerthaClareAmy XavierAmyClareBertha ClareXavierZeusYancey BerthaXavierZeusYancey AmyYanceyZeusXavier 1 st 2 nd 3 rd 1 st 2 nd 3 rd favoriteleast favoritefavorite least favorite Men’s Preference ProfileWomen’s Preference Profile
15
Example m 1 : w 1 w 2 m 2 : w 2 w 1 w 1 : m 1 m 2 w 2 : m 2 m 1 m1m1 m2m2 w2w2 w1w1
16
Example m 1 : w 1 w 2 m 2 : w 1 w 2 w 1 : m 1 m 2 w 2 : m 1 m 2 m1m1 m2m2 w2w2 w1w1
17
Example m 1 : w 1 w 2 w 3 m 2 : w 1 w 3 w 2 m 3 : w 1 w 2 w 3 w 1 : m 2 m 3 m 1 w 2 : m 3 m 1 m 2 w 3 : m 3 m 1 m 2 m1m1 m2m2 w2w2 w1w1 m3m3 w3w3
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.