Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in java Write a program that solves the classic stable marriage problem. This problem deals with a group of men and a group of women.

in java Write a program that solves the classic stable marriage problem. This problem deals with a group of men and a group of women.
* The program tries to pair them up so as to generate as many stable marriages as possible. A set of marriages is unstable if
* you can find a man and a woman who would rather be married to each other than to their current spouses (in which case the two
* would be inclined to divorce their spouses and marry each other). The input file for the program will list all of the men, one
* per line, followed by a blank line, followed by all of the women, one per line. The men and women are numbered according to their
* positions in the input file (the first man is #1, the second man is #2, and so on; the first woman is #1, the second woman is #2,
* and so on). Each input line (except for the blank line separating men from women) lists the persons name, followed by a colon,
* followed by a list of integers. These integers are the marriage partner preferences of this particular person. For example, see
* the following input line in the mens section: This line indicates that the person is named Joe and that his first choice for
* marriage is woman #10, his second choice is woman #8, and so on. Any women not listed are considered unacceptable to Joe.
* Joe: 108359202233629732161825 The stable marriage problem is solved by the following algorithm: assign each person to be free.
while (some man M with a nonempty preference list is free){
W = first woman on M's list.
if (some man P is engaged to W){
assign P to be free.
}
* assign M and W to be engaged to each other.
for (each successor Q of M who is on W's list){
delete W from Q's preference list.
delete Q from W's preference list.
}
}
* Consider the following input:
Man 1: 4123
Man 2: 2314
Man 3: 2431
Man 4: 3142
Woman 1: 4132
Woman 2: 1324
Woman 3: 1234
Woman 4: 4132
* The following is a stable marriage solution for this input:
Man 1 and Woman 4
Man 3 and Woman 2
Man 2 and Woman 3
Man 4 and Woman 1
*/

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 2 Lnai 6322

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215882X, 978-3642158827

More Books

Students also viewed these Databases questions

Question

Define the term "Leasing"

Answered: 1 week ago

Question

What do you mean by Dividend ?

Answered: 1 week ago

Question

What is database?

Answered: 1 week ago

Question

What are Mergers ?

Answered: 1 week ago