Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Stable Matching in Java programming language please Idea: Given an instance of STABLEMATCHING and a match determine whether the match is stable and if not

Stable Matching in Java programming language please

image text in transcribedimage text in transcribed

Idea: Given an instance of STABLEMATCHING and a match determine whether the match is stable and if not give one instability Input Format: The input file will be called inputl.txt and be in the same directory as the java and class files. Line 0 will be a single integer n, the number of men (or women). Lines 1 to n will be the preferences of the n men where each line is a space seperated o the n women where each line is a space seperated permutation of (1,2,...,n). Line 2n1 will be a permutation of {1, 2, 3, , ?} which represents a matching. In particular, the ith item in the permutation is the number of the woman with which man i is matched permutation of {1,2,...,n). Lines n1 to n+n will be the preferences of Output: Yes (if the match is stable) or No and an ordered pair representing an instability (if the match is unstable) Examples: If there were 2 men (and women), both men prefered woman 1, both women prefered man 1, and you wanted to check the match M1-W1, M2-W2 then the input would be 1 2 1 2 1 2 1 2 and the output would be es because the matching is stable. If there were 2 men (and women), both men prefered woman 1, both women prefered man 1, and you wanted to check the match M1-W2, M2-W1 then the input would be 2 1 2 1 2 1 2 and the output woud be because man 1 prefers woman 1 to his current match and woman 1 prefers man 1 to her current match. If there were 3 men (and women), all men prefered woman 1 to woman 2 and woman 2 to woman 3, the women differed in their preferences (eg woman 1 ordered the men 1, 3, 2), and you wanted to check the match Ml-W2, M2-W3, M3-W1 then the input would be 1 2 3 1 2 3 1 2 3 1 3 2 3 1 2 2 1 3 2 3 1 and the output woud be Idea: Given an instance of STABLEMATCHING and a match determine whether the match is stable and if not give one instability Input Format: The input file will be called inputl.txt and be in the same directory as the java and class files. Line 0 will be a single integer n, the number of men (or women). Lines 1 to n will be the preferences of the n men where each line is a space seperated o the n women where each line is a space seperated permutation of (1,2,...,n). Line 2n1 will be a permutation of {1, 2, 3, , ?} which represents a matching. In particular, the ith item in the permutation is the number of the woman with which man i is matched permutation of {1,2,...,n). Lines n1 to n+n will be the preferences of Output: Yes (if the match is stable) or No and an ordered pair representing an instability (if the match is unstable) Examples: If there were 2 men (and women), both men prefered woman 1, both women prefered man 1, and you wanted to check the match M1-W1, M2-W2 then the input would be 1 2 1 2 1 2 1 2 and the output would be es because the matching is stable. If there were 2 men (and women), both men prefered woman 1, both women prefered man 1, and you wanted to check the match M1-W2, M2-W1 then the input would be 2 1 2 1 2 1 2 and the output woud be because man 1 prefers woman 1 to his current match and woman 1 prefers man 1 to her current match. If there were 3 men (and women), all men prefered woman 1 to woman 2 and woman 2 to woman 3, the women differed in their preferences (eg woman 1 ordered the men 1, 3, 2), and you wanted to check the match Ml-W2, M2-W3, M3-W1 then the input would be 1 2 3 1 2 3 1 2 3 1 3 2 3 1 2 2 1 3 2 3 1 and the output woud be

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

OpenStack Trove

Authors: Amrith Kumar, Douglas Shelley

1st Edition

1484212215, 9781484212219

More Books

Students also viewed these Databases questions

Question

Understand developments in knowledge creation and management

Answered: 1 week ago

Question

=+j Improve the effectiveness of global and virtual teams.

Answered: 1 week ago