(Latest Revision: Mon Jul 12, 2022) SOLUTION TO Take Home Exercise #1

Take Home Exercise #1

SOLUTION TO:
CS 4400 Practice Exercise
Stable Matching Problem


==============================
==============================
Your Assignment:

Process the following input in the same manner the sample input was 
processed.

Produce the same kind of script (step-by-step) of the actions taken by 
the Gale-Shapley algorithm, plus write what the final matching is, 
in the same format as the sample.

The men are Abe, Ben, Cal, and Zeus.  
The women are Eve, Fey, Gem, and Erika.

The preference lists are 

Abe	Fey	Eve	Erika	Gem
Ben	Fey	Eve	Gem	Erika
Cal	Fey	Erika	Gem	Eve
Zeus	Fey	Eve	Erika	Gem
				
Eve	Zeus	Abe	Ben	Cal
Fey	Cal	Ben	Abe	Zeus
Gem	Ben	Cal	Zeus	Abe
Erika	Ben	Zeus	Cal	Abe


A solution given by the Gale-Shapley Algorithm:

Abe proposes to Fey.
Fey pairs with Abe because she is free.
Ben proposes to Fey.
Fey rejects Abe.
Fey pairs with Ben because she likes him more.
Abe becomes free.
Abe proposes to Eve.
Eve pairs with Abe because she is free.
Cal proposes to Fey.
Fey rejects Ben.
Fey pairs with Cal because she likes him more.
Ben becomes free.
Ben proposes to Eve.
Eve rejects Ben because she likes her current match, Abe, more.
Ben remains free.
Ben proposes to Gem.
Gem pairs with Ben because she is free.
Zeus proposes to Fey.
Fey rejects Zeus because she likes her current match, Cal, more.
Zeus remains free.
Zeus proposes to Eve.
Eve rejects Abe.
Eve pairs with Zeus because she likes him more.
Abe becomes free.
Abe proposes to Erika.
Erika pairs with Abe because she is free.
Now everyone has a match.


Here Are The Matches:

   WOMEN     MEN
     Eve    Zeus
     Fey     Cal
     Gem     Ben
   Erika     Abe