Question: Overview: Your program will be given an instance of STABLEMARRIAGE and a matching and will determine whether that matching is stable. If it is stable

 Overview: Your program will be given an instance of STABLEMARRIAGE and
a matching and will determine whether that matching is stable. If it
is stable it will simply state that. If it is not stable

Overview: Your program will be given an instance of STABLEMARRIAGE and a matching and will determine whether that matching is stable. If it is stable it will simply state that. If it is not stable it will list 1 instability. Details: The input will come from a file called input.txt which will be placed in the same directory as your java file. The first line of the file will have a single integer value N which will be the number of men (or women since the number of men equals the number of women). The next N lines will be the whitespace separated preference lists of the N men (ie each of the next lines will be a permutation of 1, 2, ..., N). The next N lines will be the whitespace separated preference lists of the N women. The next N lines will be a whitespace separated matching. See the sample input below for examples. Your program will determine whether the matching is stable and output either Stable" or "Unstable XY" where man X prefers woman Y to his partner and woman Y prefers man X to her partner. The obvious way to way to design the program is to check every man/woman pair to determine whether it is an instability. This is acceptable. There are simple ways to speed up the process. You are encouraged to use any technique you understand. Sample execution: If input.txt contains 3 1 2 3 231 3 1 2 3 2 1 1 3 2 213 1 2 2 3 31 the the output should be Stable If input.txt contains 3 1 2 3 2 3 1 3 1 2 3 2 1 1 3 2 2 1 3 13 21 32 the the output should be Unstable 12 or Unstable 23 or Unstable 31 There are 3 valid outputs because there are 3 instabilities. consist of 1 or more dot-java tiles (no class files, zip files, input files or other files should be submitted). Each file must have your name and which project you are submitting as comments on the first 2 lines. not be placed into any package (for the java pedants, it must be in the default package). be designed and formatted reasonably correct indentation, no excessively long lines, no excessively long methods, has useful method/variable names, etc) have one file called Project 1.javn. compile using the command "javac Project 1 java' run using the command Java Project, accept input from a filo called input.txt in the same directory as the java file(s) formatted precisely as described above

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!