0% found this document useful (0 votes)
97 views

To Solve Stable Marriage Problem.: Lab Exercise 4 - Week 5

This document provides instructions for a lab exercise to implement the Gale-Shapley algorithm to solve the stable marriage problem. The stable marriage problem aims to match n men and n women for marriage so that there are no two people of the opposite sex who would both rather have each other than their assigned partners. Students are asked to input preference rankings for men and women and output matched pairs. They are also asked to comment on whether the solution is optimal.

Uploaded by

Pawan Nani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views

To Solve Stable Marriage Problem.: Lab Exercise 4 - Week 5

This document provides instructions for a lab exercise to implement the Gale-Shapley algorithm to solve the stable marriage problem. The stable marriage problem aims to match n men and n women for marriage so that there are no two people of the opposite sex who would both rather have each other than their assigned partners. Students are asked to input preference rankings for men and women and output matched pairs. They are also asked to comment on whether the solution is optimal.

Uploaded by

Pawan Nani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Design and Analysis of Algorithms | IT252

Lab Exercise 4 | Week 5

Implement Gale–Shapley algorithm to solve stable marriage problem.

The stable marriage problem has been stated as follows:


Given n men and n women, where each person has ranked all
members of the opposite sex in order of preference, marry the men
and women together such that there are no two people of opposite sex
who would both rather have each other than their current partners.
When there are no such pairs of people, the set of marriages is
deemed stable.

Input: 2D matrix of size (2*N)*N where N is number of women or men. Rows


from 0 to N-1 represent preference lists of men and rows from N to 2*N – 1
represent preference lists of women. Men are numbered from 0 to N-1 and
women are numbered from N to 2*N – 1.
Output: The output is list of married pairs.
While the solution is stable, comment on the optimality of the solution.

You might also like