1 | | B | E | A | D | free |
2 | | B | E | C | D | engaged |
3 | | C | B | A | E | engaged |
4 | | | D | B | E | engaged |
5 | A | B | D | E | C | free |
|
A | 3 | 5 | 2 | 1 | 4 | engaged |
B | 5 | 2 | 1 | 4 | 3 | free |
C | 4 | 3 | 5 | 1 | 2 | engaged |
D | 1 | 2 | 3 | 4 | 5 | engaged |
E | 2 | 3 | 4 | 1 | 5 | free |
m = 1
Again, this could be 5.
B is 1's current first choice and she is free so
S = {(4,C), (2,A), (3,D), (1,B)}
We will mark both as engaged and remove B from 1's list
1 | | | E | A | D | engaged |
2 | | B | E | C | D | engaged |
3 | | C | B | A | E | engaged |
4 | | | D | B | E | engaged |
5 | A | B | D | E | C | free |
|
A | 3 | 5 | 2 | 1 | 4 | engaged |
B | 5 | 2 | 1 | 4 | 3 | engaged |
C | 4 | 3 | 5 | 1 | 2 | engaged |
D | 1 | 2 | 3 | 4 | 5 | engaged |
E | 2 | 3 | 4 | 1 | 5 | free |
m = 5
A is 5's first choice, but she is engaged to 2,
A prefers 5 to 2
C breaks the engagement with 2, who becomes free
C becomes engaged to 5.
S = {(4,C), (5,A), (3,D), (1,B)}
Mark 5 as engaged
Remove A from 5's list
Mark 2 as free
1 | | | E | A | D | engaged |
2 | | B | E | C | D | free |
3 | | C | B | A | E | engaged |
4 | | | D | B | E | engaged |
5 | | B | D | E | C | engaged |
|
A | 3 | 5 | 2 | 1 | 4 | engaged |
B | 5 | 2 | 1 | 4 | 3 | engaged |
C | 4 | 3 | 5 | 1 | 2 | engaged |
D | 1 | 2 | 3 | 4 | 5 | engaged |
E | 2 | 3 | 4 | 1 | 5 | free |
m = 2
B is 2's current first choice, but she is engaged to 1,
B prefers 2 to 1
B breaks the engagement with 1, who becomes free
B becomes engaged to 2.
S = {(4,C), (5,A), (3,D), (2,B)}
Mark 2 as engaged
Remove B from 2's list
Mark 1 as free
1 | | | E | A | D | free |
2 | | | E | C | D | engaged |
3 | | C | B | A | E | engaged |
4 | | | D | B | E | engaged |
5 | | B | D | E | C | engaged |
|
A | 3 | 5 | 2 | 1 | 4 | engaged |
B | 5 | 2 | 1 | 4 | 3 | engaged |
C | 4 | 3 | 5 | 1 | 2 | engaged |
D | 1 | 2 | 3 | 4 | 5 | engaged |
E | 2 | 3 | 4 | 1 | 5 | free |
m = 1
E is 1's current first choice and she is free so
S = {(4,C), (5,A), (3,D), (2,B), (1,E)}
We will mark both as engaged and remove E from 1's list
1 | | | | A | D | engaged |
2 | | | E | C | D | engaged |
3 | | C | B | A | E | engaged |
4 | | | D | B | E | engaged |
5 | | B | D | E | C | engaged |
|
A | 3 | 5 | 2 | 1 | 4 | engaged |
B | 5 | 2 | 1 | 4 | 3 | engaged |
C | 4 | 3 | 5 | 1 | 2 | engaged |
D | 1 | 2 | 3 | 4 | 5 | engaged |
E | 2 | 3 | 4 | 1 | 5 | engaged |
All men are engaged, so the algorithm is done.
Is this stable?
-
1 | C | B | E | A | D | free |
2 | A | B | E | C | D | free |
3 | D | C | B | A | E | free |
4 | A | C | D | B | E | free |
5 | A | B | D | E | C | free |
|
A | 3 | 5 | 2 | 1 | 4 | free |
B | 5 | 2 | 1 | 4 | 3 | free |
C | 4 | 3 | 5 | 1 | 2 | free |
D | 1 | 2 | 3 | 4 | 5 | free |
E | 2 | 3 | 4 | 1 | 5 | free |
|
- S = {(5,A), (2,B), (4,C), (3,D), (1,E)}
- Unknown {A, B, C, D, E, 1, 2, 3, 4, 5}
- Might Swap {}
- (5,A)
- 5 preferred A so he will not swap ever
- A preferred 3 to 5, so there is a chance here.
- Unknown {B, C, D, E, 1, 2, 3, 4}
- Might Swap {A:3}
- (3,D)
- 3 preferred D so he will not swap ever.
- So this rules out a swap for A.
- D preferred 1 and 2 to 3 so there is a chance here.
- Unknown {B, C, E, 1, 2, 4}
- Might Swap {D:1,2}
- (4,C)
- 4 preferred A, but a is not willing to swap for anyone but 3.
- C is 4's second choice and since he can not get A, he will not swap for anyone else.
- C preferred 4 so she will not swap.
- Unknown {B, E, 1, 2}
- Might Swap {D:1,2}
- (2,B)
- 2 preferred A to B, but she will not swap for him so he will not swap for anyone else.
- B preferred 5 to 2, but he will not swap so she will not swap for anyone else.
- Unknown {E, 1}
- Might Swap {D:1}
- (1,E)
- 1 preferred C and B to E, but they will not swap.
- Also D is the only possible swap left for 1, and they were last on 1's list.
- So the solution is correct.
| | | | |