Docsity

Data Structures and Algorithms: Stable Matching and Dijkstra's Algorithm, Study notes of Introduction to Computers

Toggle sidebar
bg1
Data Structures and Algorithms - COMS21103
Stable Matching and Dijkstra’s Algorithm Problem Sheet
A: Stable Matching A quick overview of the Gale-Shapley algorithm. For n
men (m1, m2, . . . mn) and nwomen (w1, w2, . . . wn) each with strict preference
lists.
1. Let ibe the smallest value such that miis unmatched.
2. miproposes to the most desirable woman (according to his list) that hasn’t
already rejected him.
3. She accepts if either a) she is unmatched or b) she finds mimore desirable
than her current match (who becomes unmatched).
4. Repeated until all men are matched.
Lemma 1. The Gale-Shapley algorithm with the men as proposers gives the
worst possible valid partner for each woman.
1. Prove Lemma 1.
Lemma 2. The Gale-Shapley algorithm always gives the best possible valid pair-
ing for each man.
2. Use the statement and proof (given in lectures) of Lemma 2 to show that
the Gale-Shapley algorithm gives the same matching regardless of how the
next unmatched man to be considered is picked (this is step 1 above).
3. Show how to choose suitable data structures for the Gale-Shapley algo-
rithm so that its running time is O(n2). You can assume there are n
women and nmen to be matched.
4. Consider the ‘stable roommate’ problem where n people rank each other
in order of preference (assume n is even). The task is to pair up the
people in a perfect matching as in the stable matching problem shown in
lectures but this time there are no genders. That is anyone can match with
anyone else. Give an example where there is no stable matching possible
and explain why this is the case.
We now consider an extension of the stable matching problem to include
‘good’ and ‘bad’ people. The town has nmen and nwomen all with preference
lists as before. Further assume that there are k‘good’ men and k‘good’ women.
Anyone not ‘good’ is ‘bad’. We are told that each man (woman) would rather
marry a ‘good’ woman (man) than any ‘bad’ woman (man).
5. Show that in every stable matching, every good man is married to a good
woman.
1
pf2

Partial preview of the text

Download Data Structures and Algorithms: Stable Matching and Dijkstra's Algorithm and more Study notes Introduction to Computers in PDF only on Docsity!

Data Structures and Algorithms - COMS

Stable Matching and Dijkstra’s Algorithm Problem Sheet

A: Stable Matching A quick overview of the Gale-Shapley algorithm. For n men (m 1 , m 2 ,... mn) and n women (w 1 , w 2 ,... wn) each with strict preference lists.

  1. Let i be the smallest value such that mi is unmatched.
  2. mi proposes to the most desirable woman (according to his list) that hasn’t already rejected him.
  3. She accepts if either a) she is unmatched or b) she finds mi more desirable than her current match (who becomes unmatched).
  4. Repeated until all men are matched.

Lemma 1. The Gale-Shapley algorithm with the men as proposers gives the worst possible valid partner for each woman.

  1. Prove Lemma 1.

Lemma 2. The Gale-Shapley algorithm always gives the best possible valid pair- ing for each man.

  1. Use the statement and proof (given in lectures) of Lemma 2 to show that the Gale-Shapley algorithm gives the same matching regardless of how the next unmatched man to be considered is picked (this is step 1 above).
  2. Show how to choose suitable data structures for the Gale-Shapley algo- rithm so that its running time is O(n^2 ). You can assume there are n women and n men to be matched.
  3. Consider the ‘stable roommate’ problem where n people rank each other in order of preference (assume n is even). The task is to pair up the people in a perfect matching as in the stable matching problem shown in lectures but this time there are no genders. That is anyone can match with anyone else. Give an example where there is no stable matching possible and explain why this is the case.

We now consider an extension of the stable matching problem to include ‘good’ and ‘bad’ people. The town has n men and n women all with preference lists as before. Further assume that there are k ‘good’ men and k ‘good’ women. Anyone not ‘good’ is ‘bad’. We are told that each man (woman) would rather marry a ‘good’ woman (man) than any ‘bad’ woman (man).

  1. Show that in every stable matching, every good man is married to a good woman.

B: Dijkstra’s Algorithm

  1. Prove the maintenance step in the program correctness for Dijkstra’s al- gorithm as described in the lecture notes which was left unproven in the lecture.
  2. Dijkstra’s algorithm requires that all the edges weights in the graph are positive. Give an example of a graph with negative weighted edges for which Dijkstra’s algorithm fails to find the shortest paths. Explain why this is the case. Your example should be one in which shortest paths exist for all nodes (i.e. free from negative weight cycles).