Question: 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


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
Get step-by-step solutions from verified subject matter experts
