Setup:
How should we match hospitals and residents?
Problem formalized by Gale & Shapley, 1962
Central problem in economics
And recently: Marriage Pact
Example:
hospitals
A B
residents
a b
preferences
a: A B
b: A B
A: a b
B: a b
hospitals
A B
residents
a b
preferences
a: A B
b: A B
A: a b
B: a b
Goal: find a matching where no hospital-resident pair has an incentive to deviate
hospitals
A B
residents
a b
preferences
a: A B
b: A B
A: a b
B: a b
Consider matching (a, B), (b, A)
The pair (a, A)
is a blocking pair.
A matching without blocking pairs is stable.
hospitals
A B
residents
a b
preferences
a: A B
b: A B
A: a b
B: a b
Consider matching (a, A), (b, B)
Continue until all residents arrive
a
proposalb
proposalB
refusala
proposalc
proposalA
refusalc
proposalB
refusalb
proposalA
refusala
proposalImplement McVitie & Wilson algorithm to find stable matchings!
Java uses a lot of brackets:
{ ... }
( ... )
[ ... ]
If expression are properly bracketed, Java compiler complains!
This expression
public class HelloWorld {
public static void main(String[] args)} {
System.out.println("Hello, World!");
}
}
but with just the brackets:
{ ( [ ] ) } { ( ) } }
When is an expression properly bracketed?
{ ( [ ] ) } { ( ) } }
okay?{ ( [ ] ) } } { ( ) } }
not?A bracketed expression is balanced if
{ { { } } { } { } }
{ { } } } { }
{ { { } } { } { } }
{ { { } } { } { } }