Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 - Stable Matching You are to write a Java program Your program must read a configuration file the name of which is entered as

image text in transcribed image text in transcribedimage text in transcribed

1 - Stable Matching You are to write a Java program Your program must read a configuration file the name of which is entered as a command line parameter. The configuration file represents the matching preferences for n men and n women. The first readable line of the file consists of a single decimal integer value, n, giving the the number of men/women. This is followed by n lines, one for each man having the form me iu iz... in This line means that man k prefers women iu iz... sa in strictly decreasing order, where iu ik ... in is a permutation of the integers from 1 to n. The n lines, one for each man, are followed by another n lines, one for each woman, having the form we in ip... In This line means that woman k prefers men in 12... is in strictly decreasing order, where is iz... i, is a permutation of the integers from 1 to n. In summary, this is the format of a configuration file with no comments or blank lines: n mi ini..... mn lle... wl in 12... wn in 12..... Your Stable.java program should read a configuration file conforming to this format from a file provided as the first command line argument, and it should produce output to a file provided as the second command line argument. The output file reproduces the input with all whitespace and comments removed, except for a single space that separates the items in the lines for men and women. This output should be immediately followed by n "pairs' lines describing a stable matching as produced by the Gale-Shipley algorithm as given in your text. Your output should match the following format EXACTLY: n ml in 12 ... in mnie... wl in 12... wn ile..... m2 W22 mn Win In this output, the sequence il, i2, ..., in given in the pairs lines is a permutation of the integers 1 to n, and the pairs (m1, wa), (m2,w22 ), (mn, Wain) form a stable perfect match based on the preferences given on the n lines of men and the n lines of women. There should be no whitespace or comments in this output except for a single space between entries on the same line. Example: Consider an input file named 3. in with the following contents (and with no errors): 2 1 mi 3 1 m2 3 2 m3 1 3 2 wl 2 w2 1 2 3 w3 2 1 3 13 I should be able to run your compiled Stable program as follows: java Stable 3.in 3.out Your output in 3. out should look EXACTLY like the following: 3 ml 312 m2 3 2 1 m3 1 3 2 wl 2 1 3 w2 1 2 3 W3 2 1 3 ml w1 m2 w3 m3 w2 Here (ml,wl), (m2,w3), and (m3,w2) is a perfect stable matching based on the preferences given by the m-lines and w-lines. The only exception to EXACTLY is that the pairs can be in any order. For example, this is also acceptable: 3 ml 3 12 m2 3 2 1 m3 1 3 2 wl 2 1 3 w2 1 2 3 w3 213 m2 w3

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_2

Step: 3

blur-text-image_3

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

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions

Question

Should project teams be allowed to evolve by themselves?

Answered: 1 week ago

Question

Buddy Dog Foods management to change its focus?

Answered: 1 week ago

Question

=+ If strikes occur, are they legally regulated?

Answered: 1 week ago

Question

=+industrial action Under what circumstances can unions strike?

Answered: 1 week ago

Question

=+What forms of industrial action are common?

Answered: 1 week ago