Menu

[solved]-Assignment Implement Algorithm Determine Teams Sports League Division Eliminated Playoffs Q39094323

The assignment is to implement an algorithm to determine whichteams in a sports league division have been eliminated from theplayoffs. A Java template has been provided containing an emptymethod BaseballElimination, which takes a single argumentconsisting of a Scanner object which connects you to the inputconsisting of the data related to a division of teams within asports league. The expected behavior of the method is as follows:Input: A baseball division consisting of teams. Output: AnArrayList consisting of all the teams that have been eliminatedfrom the league playoffs. We will assume that the team with themost wins in the division at the end of the season is the only teamto make the playoffs. So, a team is eliminated from the playoffs ifthey cannot possibly win as many games as some other team in thedivision. You may use the FordFulkerson, FlowNetwork, and FlowEdgeclasses from the Algorithms (Sedgewick) textbook through theagls4.jar file. You may not change any of these classes and thusyou do not need to include this code in your program.

The testing code in the main function of the template reads aninput file containing all the necessary data for a sports division,relevant to this problem. It passes this input file as a Scannerstream to the BaseballElimination method which builds an ArrayListcalled eliminated, a list of all the eliminated teams you havefound. The input files will have the following format for adivision in a league: an integer representing the number of teamsin the division followed by, for each team, the team name, theirnumber of wins, their number of remaining games (total), an orderedlist of the number of remaining inter-divisional games between theteam and the rest of the division (one for each divisional team).Thus, for the example we looked at in class i

Team wins games left vs. vs. 1 vs. 2 vs. 3 vs. 4 0 New York 75 Baltimore Boston Toronto | 4 Detroit – 49 | 27 3 4 100- Detroi

the input file, teams5.txt, will be

New_York 75 28 0 3 873 Baltimore 71 28 30 274 Boston 69 27 8 2000 Toronto 63 27 77000 Detroit 49 27 34000

The output of a model solution on the division above is given inthe listing below

. Reading input values from teams5.txt. Teams eliminated:[Detroit]

We have to create the method Baseball elimination, seebelow the code of the all program.

import edu.princeton.cs.algs4.*; import java.util.*; import java.io.File; public class BaseballElimination public ArrayList<S

Here is another example

input CIA 33 01 02 Ghaddafi 2 2 1 0 0 1 Bin_Ladin 3 0 0 0 0 0 Obama 4 3 2 1 0 0

output Teams eliminated: [Ghaddafi, Bin_Ladin)

Team wins games left vs. vs. 1 vs. 2 vs. 3 vs. 4 0 New York 75 Baltimore Boston Toronto | 4 Detroit – 49 | 27 3 4 100- Detroit New_York 75 28 0 3 873 Baltimore 71 28 30 274 Boston 69 27 8 2000 Toronto 63 27 77000 Detroit 49 27 34000 import edu.princeton.cs.algs4.*; import java.util.*; import java.io.File; public class BaseballElimination public ArrayList<String> eliminated = new ArrayList<String>(); public BaseballElimination (Scanner s) { ΗΤΗΤΗ public static void main(String[] args) { In in = new In (args[0]); FlowNetwork G = new FlowNetwork (in); Stdout.println(G); Scanner 3; if (args.length > 0) { try{ s = new Scanner (new File(args[0])); } catch (java.io.FileNotFoundException e) { System.out.printf(“Unable to open sn”, args[0]); return; System.out.printf(“Reading input values from $s.n”, args[0]); }else{ s = new Scanner(System.in); System.out.printf(“Reading input values from stdin. n”); BaseballElimination be = new BaseballElimination(s); if (be. eliminated.size() == 0) System.out.println(“No teams have been eliminated.”); else System.out.println(“Teams eliminated: ” + be. eliminated); CIA 33 01 02 Ghaddafi 2 2 1 0 0 1 Bin_Ladin 3 0 0 0 0 0 Obama 4 3 2 1 0 0 Teams eliminated: [Ghaddafi, Bin_Ladin) Show transcribed image text Team wins games left vs. vs. 1 vs. 2 vs. 3 vs. 4 0 New York 75 Baltimore Boston Toronto | 4 Detroit – 49 | 27 3 4 100- Detroit
New_York 75 28 0 3 873 Baltimore 71 28 30 274 Boston 69 27 8 2000 Toronto 63 27 77000 Detroit 49 27 34000
import edu.princeton.cs.algs4.*; import java.util.*; import java.io.File; public class BaseballElimination public ArrayList eliminated = new ArrayList(); public BaseballElimination (Scanner s) { ΗΤΗΤΗ public static void main(String[] args) { In in = new In (args[0]); FlowNetwork G = new FlowNetwork (in); Stdout.println(G); Scanner 3; if (args.length > 0) { try{ s = new Scanner (new File(args[0])); } catch (java.io.FileNotFoundException e) { System.out.printf(“Unable to open sn”, args[0]); return; System.out.printf(“Reading input values from $s.n”, args[0]); }else{ s = new Scanner(System.in); System.out.printf(“Reading input values from stdin. n”); BaseballElimination be = new BaseballElimination(s); if (be. eliminated.size() == 0) System.out.println(“No teams have been eliminated.”); else System.out.println(“Teams eliminated: ” + be. eliminated);
CIA 33 01 02 Ghaddafi 2 2 1 0 0 1 Bin_Ladin 3 0 0 0 0 0 Obama 4 3 2 1 0 0
Teams eliminated: [Ghaddafi, Bin_Ladin)

Expert Answer


Answer to The assignment is to implement an algorithm to determine which teams in a sports league division have been eliminated fr… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *