Créer une présentation
Télécharger la présentation

Download

Download Presentation

The Stable Roommates Problem and Some Extensions David Manlove University of Glasgow

127 Vues
Download Presentation

Télécharger la présentation
## The Stable Roommates Problem and Some Extensions David Manlove University of Glasgow

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -

**The Stable Roommates Problem**and Some Extensions David Manlove University of Glasgow Department of Computing Science Supported by EPSRC grant GR/M13329 and Nuffield Foundation award NUF-NAL-02**Stable Roommates (SR): definition**• Input:2n persons; each person ranks all 2n-1 • other persons in strict order • Output: a stable matching • Definitions • A matchingis a set of n disjoint pairs of persons • A blocking pair of a matching M is a pair of persons {p,q}Msuch that: • p prefers q to his partner in M, and • q prefers p to his partner in M • A matching is stable if it admits no blocking pair**Stable Roommates (SR): definition**• Input:2n persons; each person ranks all 2n-1 • other persons in strict order • Output: a stable matching • Definitions • A matchingis a set of n disjoint pairs of persons • A blocking pair of a matching M is a pair of persons {p,q}Msuch that: • p prefers q to his partner in M, and • q prefers p to his partner in M • A matching is stable if it admits no blocking pair • Example SR instance I1:1: 3 2 4 • 2: 4 3 1 • 3: 2 1 4 • 4: 1 3 2**Stable Roommates (SR): definition**• Input:2n persons; each person ranks all 2n-1 • other persons in strict order • Output: a stable matching • Definitions • A matching is a set of n disjoint pairs of persons • A blocking pair of a matching M is a pair of persons {p,q}Msuch that: • p prefers q to his partner in M, and • q prefers p to his partner in M • A matching is stableif it admits no blocking pair • Example SR instance I1:1: 3 2 4 • 2: 4 3 1 • 3: 2 1 4 • 4: 1 3 2**Stable Roommates (SR): definition**• Input:2n persons; each person ranks all 2n-1 • other persons in strict order • Output: a stable matching • Definitions • A matching is a set of n disjoint pairs of persons • A blocking pair of a matching M is a pair of persons {p,q}Msuch that: • p prefers q to his partner in M, and • q prefers p to his partner in M • A matching is stableif it admits no blocking pair • Example SR instance I1:1: 3 2 4 • 2: 4 3 1 • 3: 2 1 4 • 4: 1 3 2 • The matching is not stable as {1,3} blocks.**Stable matching in I1:1: 3 2 4**2: 4 3 1 3: 2 1 4 4: 1 3 2**Stable matching in I1:1: 3 2 4**2: 4 3 1 3: 2 1 4 4: 1 3 2 Example SR instance I2:1: 3 2 4 2: 1 3 4 3: 2 1 4 4: 1 2 3**Stable matching in I1:1: 3 2 4**2: 4 3 1 3: 2 1 4 4: 1 3 2 Example SR instance I2:1: 3 2 4 2: 1 3 4 3: 2 1 4 4: 1 2 3**Stable matching in I1:1: 3 2 4**2: 4 3 1 3: 2 1 4 4: 1 3 2 Example SR instance I2:1: 3 2 4 2: 1 3 4 3: 2 1 4 4: 1 2 3**Stable matching in I1:1: 3 2 4**2: 4 3 1 3: 2 1 4 4: 1 3 2 Example SR instance I2:1: 3 2 4 2: 1 3 4 3: 2 1 4 4: 1 2 3 1: 3 2 4 2: 1 3 4 3: 2 1 4 4: 1 2 3**Stable matching in I1:1: 3 2 4**2: 4 3 1 3: 2 1 4 4: 1 3 2 Example SR instance I2:1: 3 2 4 2: 1 3 4 3: 2 1 4 4: 1 2 3 1: 3 2 4 2: 1 3 4 3: 2 1 4 4: 1 2 3**Stable matching in I1:1: 3 2 4**2: 4 3 1 3: 2 1 4 4: 1 3 2 Example SR instance I2:1: 3 2 4 2: 1 3 4 3: 2 1 4 4: 1 2 3 1: 3 2 4 1: 3 2 4 2: 1 3 4 2: 1 3 4 3: 2 1 4 3: 2 1 4 4: 1 2 3 4: 1 2 3**Stable matching in I1:1: 3 2 4**2: 4 3 1 3: 2 1 4 4: 1 3 2 Example SR instance I2:1: 3 2 4 2: 1 3 4 3: 2 1 4 4: 1 2 3 1: 3 2 4 1: 3 2 4 2: 1 3 4 2: 1 3 4 3: 2 1 4 3: 2 1 4 4: 1 2 3 4: 1 2 3**Stable matching in I1:1: 3 2 4**2: 4 3 1 3: 2 1 4 4: 1 3 2 Example SR instance I2:1: 3 2 4 2: 1 3 4 3: 2 1 4 4: 1 2 3 1: 3 2 4 1: 3 2 4 2: 1 3 4 2: 1 3 4 3: 2 1 4 3: 2 1 4 4: 1 2 3 4: 1 2 3 The three matchings containing the pairs {1,4}, {2,4}, {3,4} are blocked by the pairs {1,2}, {2,3}, {3,1} respectively. instance I2 has no stable matching.**Stable marriage (SM) problem**• SM is a special case of SR • Input:n men and n women; each person ranks all • n members of the opposite sex in order • Output: a stable matching • Definitions: • A matching is a set of n disjoint (man,woman) pairs • A blocking pair of a matching M is an unmatched (man,woman) pair (m,w) such that: • m prefers w to his partner in M, and • w prefers m to her partner in M • A matching is stable if it admits no blocking pair • Every instance of SM admits a stable matching • Such a matching can be found by an efficient • algorithm known as the Gale/Shapleyalgorithm**Reduction from SM to SR**An instance I of SM can be reduced to an instance J of SR such that set of stable matchings in I = set of stable matchings in J SM instance I: U={m1, m2,...,mn} is the set of men, and W={w1, w2,...,wn} is the set of women SR instance J: People comprise men in U and women in W mi’s list in J is his list in I together with the men in U\{mi} appended in arbitrary order. wi’s list in J is her list in I together with the women in W\{wi} appended in arbitrary order. Proposition: Set of stable matchings in I = set of stable matchings in J Open question: can we reduce SR to SM?**Efficient algorithm for SR**• Knuth (1976): is there an efficient algorithm • for deciding whether there exists a stable • matching, given an instance of SR? • Irving (1985) “An efficient algorithm for the • ‘Stable Roommates’ Problem”, Journal of • Algorithms, 6:577-595 • given an instanceof SR, decides whether a stable matching exists; if so, finds one • Algorithm is in two phases • Phase 1: similar to GS algorithm for SM • Phase 2: elimination of “rotations” • Phase 1: • if p proposes to q, p becomesassigned toq, and q becomes assigned fromp • “assigned” relation is not necessarily symmetric • if anyone’s preference list becomes empty, no stable matching exists**Phase 1 of Algorithm SR**assign everyone to be free; while ((some person p has a non-empty list) and (p is not assigned to anyone)) { q := first person on p’s list; /* p proposes to q */ assign p to q;/* qis assigned from p */ for(each successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q,r}; } } 1: 4 6 2 5 3 2: 6 3 5 1 4 3: 4 5 1 6 2 4: 2 6 5 1 3 5: 4 2 3 6 1 6: 5 1 4 2 3**Phase 1 of Algorithm SR**assign everyone to be free; while ((some person p has a non-empty list) and (p is not assigned to anyone)) { q := first person on p’s list; /* p proposes to q */ assign p to q; /* qis assigned from p */ for(each successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q,r}; } } assigned to / from 1: 4 6 2 5 3 2: 6 3 5 1 4 3: 4 5 1 6 2 4: 2 6 5 1 3 5: 4 2 3 6 1 6: 5 1 4 2 3**Phase 1 of Algorithm SR**assign everyone to be free; while((some person p has a non-empty list) and (p is not assigned to anyone)) { q := first person on p’s list; /* p proposes to q */ assign p to q; /* qis assigned from p */ for(each successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q,r}; } } assigned to / from 1: 4 6 2 5 3 4 2: 6 3 5 1 4 3: 4 5 1 6 2 4: 2 6 5 1 3 1 5: 4 2 3 6 1 6: 5 1 4 2 3 p=1**Phase 1 of Algorithm SR**assign everyone to be free; while ((some person p has a non-empty list) and (p is not assigned to anyone)) { q := first person on p’s list; /* p proposes to q */ assign p to q; /* qis assigned from p */ for (each successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q,r}; } } assigned to / from 1: 4 6 2 5 3 4 2: 6 3 5 1 4 3: 4 5 1 6 2 4: 2 6 5 1 3 1 5: 4 2 3 6 1 6: 5 1 4 2 3 p=1 **Phase 1 of Algorithm SR**assign everyone to be free; while ((some person p has a non-empty list) and (p is not assigned to anyone)) { q := first person on p’s list; /* p proposes to q */ assign p to q; /* qis assigned from p */ for (each successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q,r}; } } assigned to / from 1: 4 6 2 5 3 4 2: 6 3 5 1 4 3: 4 5 1 6 2 4: 2 6 5 1 3 1 5: 4 2 3 6 1 6: 5 1 4 2 3 p=1 **Phase 1 of Algorithm SR**assign everyone to be free; while ((some person p has a non-empty list) and (p is not assigned to anyone)) { q := first person on p’s list; /* p proposes to q */ assign p to q; /* qis assigned from p */ for (each successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q,r}; } } assigned to / from 1: 4 6 2 5 3 4 2: 6 3 5 1 4 6 3: 4 5 1 6 2 4: 2 6 5 1 3 1 5: 4 2 3 6 1 6: 5 1 4 2 3 2 p=2 **Phase 1 of Algorithm SR**assign everyone to be free; while ((some person p has a non-empty list) and (p is not assigned to anyone)) { q := first person on p’s list; /* p proposes to q */ assign p to q; /* qis assigned from p */ for (each successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q,r}; } } assigned to / from 1: 4 6 2 5 3 4 2: 6 3 5 1 4 6 3: 4 5 1 6 2 4: 2 6 5 1 3 1 5: 4 2 3 6 1 6: 5 1 4 2 3 2 p=2 **Phase 1 of Algorithm SR**assign everyone to be free; while ((some person p has a non-empty list) and (p is not assigned to anyone)) { q := first person on p’s list; /* p proposes to q */ assign p to q; /* qis assigned from p */ for (each successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q,r}; } } assigned to / from 1: 4 6 2 5 3 4 2: 6 3 5 1 4 6 3: 4 5 1 6 2 5 4: 2 6 5 1 3 1 5: 4 2 3 6 1 3 6: 5 1 4 2 3 2 p=3 **Phase 1 of Algorithm SR**assign everyone to be free; while ((some person p has a non-empty list) and (p is not assigned to anyone)) { q := first person on p’s list; /* p proposes to q */ assign p to q; /* qis assigned from p */ for (each successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q,r}; } } assigned to / from 1: 4 6 2 5 3 4 2: 6 3 5 1 4 6 3: 4 5 1 6 2 5 4: 2 6 5 1 3 1 5: 4 2 3 6 1 3 6: 5 1 4 2 3 2 p=3 **Phase 1 of Algorithm SR**assign everyone to be free; while ((some person p has a non-empty list) and (p is not assigned to anyone)) { q := first person on p’s list; /* p proposes to q */ assign p to q; /* qis assigned from p */ for (each successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q,r}; } } assigned to / from 1: 4 6 2 5 3 4 2: 6 3 5 1 4 6 4 3: 4 5 1 6 2 5 4: 2 6 5 1 3 2 1 5: 4 2 3 6 1 3 6: 5 1 4 2 3 2 p=4 **Phase 1 of Algorithm SR**assign everyone to be free; while ((some person p has a non-empty list) and (p is not assigned to anyone)) { q := first person on p’s list; /* p proposes to q */ assign p to q; /* qis assigned from p */ for (each successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q,r}; } } assigned to / from 1: 4 6 2 5 3 4 2: 6 3 5 1 4 6 4 3: 4 5 1 6 2 5 4: 2 6 5 1 3 25/1 5: 4 2 3 6 1 4 3 6: 5 1 4 2 3 2 p=5 **Phase 1 of Algorithm SR**assign everyone to be free; while ((some person p has a non-empty list) and (p is not assigned to anyone)) { q := first person on p’s list; /* p proposes to q */ assign p to q; /* qis assigned from p */ for (each successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q,r}; } } assigned to / from 1: 4 6 2 5 3 2: 6 3 5 1 4 6 4 3: 4 5 1 6 2 5 4: 2 6 5 1 3 2 5 5: 4 2 3 6 1 4 3 6: 5 1 4 2 3 2 p=5 **Phase 1 of Algorithm SR**assign everyone to be free; while ((some person p has a non-empty list) and (p is not assigned to anyone)) { q := first person on p’s list; /* p proposes to q */ assign p to q; /* qis assigned from p */ for (each successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q,r}; } } assigned to / from 1: 4 6 2 5 3 6 2: 6 3 5 1 4 6 4 3: 4 5 1 6 2 5 4: 2 6 5 1 3 2 5 5: 4 2 3 6 1 4 3 6: 5 1 4 2 3 1/2 p=1 **Phase 1 of Algorithm SR**assign everyone to be free; while ((some person p has a non-empty list) and (p is not assigned to anyone)) { q := first person on p’s list; /* p proposes to q */ assign p to q; /* qis assigned from p */ for (each successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q,r}; } } assigned to / from 1: 4 6 2 5 3 6 2: 6 3 5 1 4 4 3: 4 5 1 6 2 5 4: 2 6 5 1 3 2 5 5: 4 2 3 6 1 4 3 6: 5 1 4 2 3 1 p=1 **Phase 1 of Algorithm SR**assign everyone to be free; while ((some person p has a non-empty list) and (p is not assigned to anyone)) { q := first person on p’s list; /* p proposes to q */ assign p to q; /* qis assigned from p */ for (each successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q,r}; } } assigned to / from 1: 4 6 2 5 3 6 2: 6 3 5 1 4 3 4 3: 4 5 1 6 2 5 2 4: 2 6 5 1 3 2 5 5: 4 2 3 6 1 4 3 6: 5 1 4 2 3 1 p=2 **Phase 1 of Algorithm SR**assign everyone to be free; while ((some person p has a non-empty list) and (p is not assigned to anyone)) { q := first person on p’s list; /* p proposes to q */ assign p to q; /* qis assigned from p */ for (each successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q,r}; } } assigned to / from 1: 4 6 2 5 3 6 6 2: 6 3 5 1 4 3 4 3: 4 5 1 6 2 5 2 4: 2 6 5 1 3 2 5 5: 4 2 3 6 1 4 3 6: 5 1 4 2 3 1 1 p=6 **Phase 1 of Algorithm SR**assign everyone to be free; while ((some person p has a non-empty list) and (p is not assigned to anyone)) { q := first person on p’s list; /* p proposes to q */ assign p to q; /* qis assigned from p */ for (each successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q,r}; } } assigned to / from 1: 4 6 2 5 3 6 6 2: 6 3 5 1 4 3 4 3: 4 5 1 6 2 5 2 4: 2 6 5 1 3 2 5 5: 4 2 3 6 1 4 3 6: 5 1 4 2 3 1 1 p=6 **Phase 1 of Algorithm SR**assign everyone to be free; while ((some person p has a non-empty list) and (p is not assigned to anyone)) { q := first person on p’s list; /* p proposes to q */ assign p to q; /* qis assigned from p */ for (each successor r of p in q's list) { if (r is assigned to q) break the assignment; delete the pair {q,r}; } } assigned to / from 1: 6 6 6 2: 3 5 4 3 4 3: 5 2 5 2 4: 2 5 2 5 5: 4 2 3 4 3 6: 1 1 1**Some notation**• Tdenotes the set of preference lists after Phase 1 • fT(x)denotes the first person onx’s list • sT(x)denotes the second person onx’s list • lT(x)denotes the last person onx’s list • At the termination of Phase 1: • y= fT(x) if and only if x=lT(y) • the pair {x,y} is absent if and only if x prefers • lT(x) to y, or y prefers lT(y) to x • 3. no preference list is empty • assigned to / from • 1: 6 6 6 • 2: 3 5 4 3 4 • 3: 5 2 5 2 • 4: 2 5 2 5 • 5: 4 2 3 4 3 • 6: 1 1 1**Stable tables**Any set of preference lists satisfying 1, 2 and 3 above is called a stable table Lemma: Suppose that, during the execution of Phase 1, no person’s list becomes empty. Let T denote the set of preference lists at this point. Then T is a stable table. Lemma: Suppose that, during the execution of Phase 1, some person’s list becomes empty. Then no stable matching exists. So if somebody’s list becomes empty during Phase 1, we can immediately halt. Otherwise, proceed to Phase 2…**Phase 2 of the algorithm**• Deals with the fact that the assignment relation is • not symmetric in general • involves rotation eliminations • assigned to / from • 1: 6 6 6 • 2: 3 5 4 3 4 • 3: 5 2 5 2 • 4: 2 5 2 5 • 5: 4 2 3 4 3 • 6: 1 1 1 • Let T be a stable table, and let • =(x0, y0), (x1, y1), …, (xr-1, yr-1) be a sequence of • pairs such that yi=fT(xi) and yi+1=sT(xi) for all i • (0 i r-1). • Then is called a rotation exposed inT. • Example: =(x0, y0), (x1, y1) = (3,5), (4,2) • y0 = 5 = fT(x0) y1 = 2 = fT(x1) • y1 = 2 = sT(x0) y0 = 5 = sT(x1)**Phase 2 of the algorithm**• Deals with the fact that the assignment relation is • not symmetric in general • involves rotation eliminations • assigned to / from • 1: 6 6 6 • 2: 3 5 4 3 4 • 3: 5 2 5 2 • 4: 2 5 2 5 • 5: 4 2 3 4 3 • 6: 1 1 1 • Let T be a stable table, and let • =(x0, y0), (x1, y1), …, (xr-1, yr-1) be a sequence of • pairs such that yi=fT(xi) and yi+1=sT(xi) for all i • (0 i r-1). • Then is called a rotation exposed inT. • Example: =(x0, y0), (x1, y1) = (3,5), (4,2) • y0 = 5 = fT(x0) y1 = 2 = fT(x1) • y1 = 2 = sT(x0) y0 = 5 = sT(x1)**Phase 2 of the algorithm**• Deals with the fact that the assignment relation is • not symmetric in general • involves rotation eliminations • assigned to / from • 1: 6 6 6 • 2: 3 5 4 3 4 • 3: 5 2 5 2 • 4: 25 2 5 • 5: 4 2 3 4 3 • 6: 1 1 1 • Let T be a stable table, and let • =(x0, y0), (x1, y1), …, (xr-1, yr-1) be a sequence of • pairs such that yi=fT(xi) and yi+1=sT(xi) for all i • (0 i r-1). • Then is called a rotation exposed inT. • Example: =(x0, y0), (x1, y1) = (3,5), (4,2) • y0 = 5 = fT(x0) y1 = 2 = fT(x1) • y1 = 2 = sT(x0) y0 = 5 = sT(x1)**Phase 2 of the algorithm**• Deals with the fact that the assignment relation is • not symmetric in general • involves rotation eliminations • assigned to / from • 1: 6 6 6 • 2: 3 5 4 3 4 • 3: 5 2 5 2 • 4: 2 5 2 5 • 5: 4 2 3 4 3 • 6: 1 1 1 • Let T be a stable table, and let • =(x0, y0), (x1, y1), …, (xr-1, yr-1) be a sequence of • pairs such that yi=fT(xi) and yi+1=sT(xi) for all i • (0 i r-1). • Then is called a rotation exposed inT. • Example: =(x0, y0), (x1, y1) = (3,5), (4,2) • y0 = 5 = fT(x0) y1 = 2 = fT(x1) • y1 = 2 = sT(x0) y0 = 5 = sT(x1)**Phase 2 of the algorithm**• Deals with the fact that the assignment relation is • not symmetric in general • involves rotation eliminations • assigned to / from • 1: 6 6 6 • 2: 3 5 4 3 4 • 3: 5 2 5 2 • 4: 2 52 5 • 5: 4 2 3 4 3 • 6: 1 1 1 • Let T be a stable table, and let • =(x0, y0), (x1, y1), …, (xr-1, yr-1) be a sequence of • pairs such that yi=fT(xi) and yi+1=sT(xi) for all i • (0 i r-1). • Then is called a rotation exposed inT. • Example: =(x0, y0), (x1, y1) = (3,5), (4,2) • y0 = 5 = fT(x0) y1 = 2 = fT(x1) • y1 = 2 = sT(x0) y0 = 5 = sT(x1)**Some intuition behind rotations**The rotation =(x0, y0), (x1, y1) = (3,5), (4,2) is exposed inT assigned to / from 1: 6 6 6 2: 3 5 4 3 4 3: 5 2 5 2 4: 2 5 2 5 5: 4 2 3 4 3 6: 1 1 1 x0 has a preference list of length >1, and so is not assigned to / from the same person The effect of is equivalent to supposing that:**Some intuition behind rotations**The rotation =(x0, y0), (x1, y1) = (3,5), (4,2) is exposed inT assigned to / from 1: 6 6 6 2: 3 5 4 3 4 3: 5 2 2 4: 2 5 2 5 5: 4 2 3 4 6: 1 1 1 x0 has a preference list of length >1, and so is not assigned to / from the same person The effect of is equivalent to supposing that: y0 rejects x0 **Some intuition behind rotations**The rotation =(x0, y0), (x1, y1) = (3,5), (4,2) is exposed inT assigned to / from 1: 6 6 6 2: 3 5 4 3 3/4 3: 5 2 2 2 4: 2 5 2 5 5: 4 2 3 4 6: 1 1 1 x0 has a preference list of length >1, and so is not assigned to / from the same person The effect of is equivalent to supposing that: y0 rejects x0 , so that x0 proposes to y1 **Some intuition behind rotations**The rotation =(x0, y0), (x1, y1) = (3,5), (4,2) is exposed inT assigned to / from 1: 6 6 6 2: 3 5 4 3 3 3: 5 2 2 2 4: 2 5 5 5: 4 2 3 4 6: 1 1 1 x0 has a preference list of length >1, and so is not assigned to / from the same person The effect of is equivalent to supposing that: y0 rejects x0 , so that x0 proposes to y1 , then y1 rejects x1 **Some intuition behind rotations**The rotation =(x0, y0), (x1, y1) = (3,5), (4,2) is exposed inT assigned to / from 1: 6 6 6 2: 3 5 4 3 3 3: 5 2 2 2 4: 2 5 5 5 5: 4 2 3 4 4 6: 1 1 1 x0 has a preference list of length >1, and so is not assigned to / from the same person The effect of is equivalent to supposing that: y0 rejects x0 , so that x0 proposes to y1 , then y1 rejects x1 , so that x1 proposes to y0 **** Some intuition behind rotations The rotation =(x0, y0), (x1, y1) = (3,5), (4,2) is exposed inT assigned to / from 1: 6 6 6 2: 3 5 4 3 3 3: 5 2 2 2 4: 2 5 5 5 5: 4 2 3 4 4 6: 1 1 1 x0 has a preference list of length >1, and so is not assigned to / from the same person The effect of is equivalent to supposing that: y0 rejects x0 , so that x0 proposes to y1 , then y1 rejects x1 , so that x1 proposes to y0 This is called the elimination of We denote byT / the preference lists remaining after elimination of **This isT / :**assigned to / from 1: 6 6 6 2: 3 3 3 3: 2 2 2 4: 55 5 5: 4 4 4 6: 1 1 1 It corresponds to the matching {1,6}, {2,3}, {4,5} Lemma: If T is a stable table with containing a list with at least two entries, then there is a rotation exposed in T Lemma: If T is a stable table, and T / contains no empty lists, thenT / is a stable table Lemma: If there is a stable matching contained in T and is a rotation exposed in T, then there is a stable matching contained in T / **Phase 2 of Algorithm SR**T := preference lists generated by Phase 1; while ((some list in T is of length >1) and (no list in T is empty)) { find a rotation exposed in T; T := T / ; } if (some list in T is empty) output “no stable matching exists”; else output T; /* which is a stable matching */ Algorithm found stable matching {1,6}, {2,3}, {4,5} 1: 4 6 2 5 3 2: 6 3 5 1 4 3: 4 5 1 6 2 4: 2 6 5 1 3 5: 4 2 3 6 1 6: 5 1 4 2 3 Algorithm takes cn2 steps for some constant c