Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Assignment: Write a Java program that takes 1 command line arg which is the input file name and finds all the subsets of the

The Assignment: Write a Java program that takes 1 command line arg which is the input file name and finds all the subsets of the original set that sum to the specified target number. You program must print a report to stdout that is formatted like this:

13 24 35 46 57 68 79 80 32 43 54 65 76 87 98 27 <-- this is the ORIGINAL SET YOU WERE GIVEN in the input file

438 <-- this is the SUM you are looking for in the subsets of the above set

27 98 87 76 32 46 35 24 13 <-- this is a subset of the original set. It sums to 438 27 98 87 76 80 57 13 <-- these subset lines do not have to be in any particular order

27 98 87 76 80 46 24 <-- each one must however sum to 438

27 98 87 65 43 46 35 24 13 <-- and the number of subset lines must match my solution's number exactly ... etc.

for each subset found that sums to 438 Your solution will not generate the subsets in the same order as my sorted-correct-output files. This is because my sorted-correct-output files have been post processed as follows: each subset array was sorted ascending each subset then treated as a line/string and the whole file of subset lines were sorted ascending.

To account for this my grading script will sort the lines of your out such that it can be diffed against a "correct" output file. When you examine your output it may be difficult to visually match against mine. You can count the number of lines in your output and confirm it matches the number of lines in mine. Once you hand it in the script will be the definitive judge. input file correct sorted output file

input-1.txt sorted-correct-output-1.txt

input-2.txt sorted-correct-output-2.txt

input-3.txt. sorted-correct-output-3.txt

One more thing, the correct outputs it give you can have duplicate subsets. This is a natural consequence of generating every possible subset on sets that have duplicate elements. Do not bother to purge duplicate subsets. If you do you will not match my output. Just generate all the subsets and print all that match the target sum. Other constraints/caveats for this lab You must NOT use the Math library anywhere in this program. You are not allowed to use loops to compute values such as (2 to the 16) - 1. Use bit ops or assign a HEX code 0xFFFF value into your stopping value to produce these numbers instead. Don't use hard coded numbers like 65535 You may assume a length of 16 always for your input sets. There is to be only one array allocated in this program - that array has 16 elements and holds the original set of int. NO OTHER ARRAYS ALLOWED FOR ANY REASON

input-1.txt

13 24 35 46 57 68 79 80 32 43 54 65 76 87 98 27 438

438

sorted-correct-output-1.txt

13 24 27 32 35 43 79 87 98 13 24 27 32 35 46 76 87 98 13 24 27 32 35 54 68 87 98 13 24 27 32 35 54 76 79 98 13 24 27 32 35 57 65 87 98 13 24 27 32 35 65 68 76 98 13 24 27 32 35 65 76 79 87 13 24 27 32 43 46 68 87 98 13 24 27 32 43 46 76 79 98 13 24 27 32 43 54 68 79 98 13 24 27 32 43 57 65 79 98 13 24 27 32 43 57 68 76 98 13 24 27 32 43 57 76 79 87 13 24 27 32 43 65 68 79 87 13 24 27 32 46 54 57 87 98 13 24 27 32 46 54 65 79 98 13 24 27 32 46 54 68 76 98 13 24 27 32 46 54 76 79 87 13 24 27 32 46 57 65 76 98 13 24 27 32 46 65 68 76 87 13 24 27 32 54 57 65 68 98 13 24 27 32 54 57 65 79 87 13 24 27 32 54 57 68 76 87 13 24 27 32 54 65 68 76 79 13 24 27 35 43 46 65 87 98 13 24 27 35 43 54 57 87 98 13 24 27 35 43 54 65 79 98 13 24 27 35 43 54 68 76 98 13 24 27 35 43 54 76 79 87 13 24 27 35 43 57 65 76 98 13 24 27 35 43 65 68 76 87 13 24 27 35 46 54 65 76 98 13 24 27 35 54 57 65 76 87 13 24 27 43 46 54 57 76 98 13 24 27 43 46 54 65 68 98 13 24 27 43 46 54 65 79 87 13 24 27 43 46 54 68 76 87 13 24 27 43 46 57 65 76 87 13 24 27 43 54 57 65 68 87 13 24 27 43 54 57 65 76 79 13 24 32 35 43 46 68 79 98 13 24 32 35 43 57 68 79 87 13 24 32 35 46 54 57 79 98 13 24 32 35 46 54 68 79 87 13 24 32 35 46 57 65 68 98 13 24 32 35 46 57 65 79 87 13 24 32 35 46 57 68 76 87 13 24 32 35 46 65 68 76 79 13 24 32 35 54 57 68 76 79 13 24 32 43 46 57 68 76 79 13 24 32 43 65 76 87 98 13 24 32 46 54 57 65 68 79 13 24 35 43 46 54 57 68 98 13 24 35 43 46 54 57 79 87 13 24 35 43 46 54 68 76 79 13 24 35 43 46 57 65 68 87 13 24 35 43 46 57 65 76 79 13 24 35 43 54 57 65 68 79 13 24 35 46 54 57 65 68 76 13 24 57 79 80 87 98 13 24 68 76 79 80 98 13 27 32 35 43 46 57 87 98 13 27 32 35 43 46 65 79 98 13 27 32 35 43 46 68 76 98 13 27 32 35 43 46 76 79 87 13 27 32 35 43 54 57 79 98 13 27 32 35 43 54 68 79 87 13 27 32 35 43 57 65 68 98 13 27 32 35 43 57 65 79 87 13 27 32 35 43 57 68 76 87 13 27 32 35 43 65 68 76 79 13 27 32 35 46 54 57 76 98 13 27 32 35 46 54 65 68 98 13 27 32 35 46 54 65 79 87 13 27 32 35 46 54 68 76 87 13 27 32 35 46 57 65 76 87 13 27 32 35 54 57 65 68 87 13 27 32 35 54 57 65 76 79 13 27 32 43 46 54 57 68 98 13 27 32 43 46 54 57 79 87 13 27 32 43 46 54 68 76 79 13 27 32 43 46 57 65 68 87 13 27 32 43 46 57 65 76 79 13 27 32 43 54 57 65 68 79 13 27 32 46 54 57 65 68 76 13 27 35 43 46 54 57 65 98 13 27 35 43 46 54 57 76 87 13 27 35 43 46 54 65 68 87 13 27 35 43 46 54 65 76 79 13 27 35 43 54 57 65 68 76 13 27 54 79 80 87 98 13 27 57 76 80 87 98 13 27 65 68 80 87 98 13 27 65 76 79 80 98 13 32 35 43 46 57 65 68 79 13 32 35 43 54 76 87 98 13 32 43 46 54 65 87 98 13 32 43 54 57 65 76 98 13 32 43 54 65 68 76 87 13 35 46 79 80 87 98 13 35 57 68 80 87 98 13 35 57 76 79 80 98 13 35 65 68 79 80 98 13 35 68 76 79 80 87 13 43 57 68 79 80 98 13 46 54 68 79 80 98 13 46 57 65 79 80 98 13 46 57 68 76 80 98 13 46 57 76 79 80 87 13 46 65 68 79 80 87 13 54 57 68 79 80 87 13 57 65 68 76 79 80 24 27 32 35 43 46 54 79 98 24 27 32 35 43 46 57 76 98 24 27 32 35 43 46 65 68 98 24 27 32 35 43 46 65 79 87 24 27 32 35 43 46 68 76 87 24 27 32 35 43 54 57 68 98 24 27 32 35 43 54 57 79 87 24 27 32 35 43 54 68 76 79 24 27 32 35 43 57 65 68 87 24 27 32 35 43 57 65 76 79 24 27 32 35 46 54 57 65 98 24 27 32 35 46 54 57 76 87 24 27 32 35 46 54 65 68 87 24 27 32 35 46 54 65 76 79 24 27 32 35 54 57 65 68 76 24 27 32 43 46 54 57 68 87 24 27 32 43 46 54 57 76 79 24 27 32 43 46 54 65 68 79 24 27 32 43 46 57 65 68 76 24 27 35 43 46 54 57 65 87 24 27 35 43 46 54 65 68 76 24 27 43 79 80 87 98 24 27 46 76 80 87 98 24 27 54 68 80 87 98 24 27 54 76 79 80 98 24 27 57 65 80 87 98 24 27 65 68 76 80 98 24 27 65 76 79 80 87 24 32 35 43 46 54 57 68 79 24 32 35 43 54 65 87 98 24 32 43 46 54 65 76 98 24 32 43 54 57 65 76 87 24 32 57 68 79 80 98 24 35 46 68 80 87 98 24 35 46 76 79 80 98 24 35 54 68 79 80 98 24 35 57 65 79 80 98 24 35 57 68 76 80 98 24 35 57 76 79 80 87 24 35 65 68 79 80 87 24 43 46 68 79 80 98 24 43 57 68 79 80 87 24 46 54 57 79 80 98 24 46 54 68 79 80 87 24 46 57 65 68 80 98 24 46 57 65 79 80 87 24 46 57 68 76 80 87 24 46 65 68 76 79 80 24 54 57 68 76 79 80 27 32 35 43 46 54 57 65 79 27 32 35 43 46 54 57 68 76 27 32 35 79 80 87 98 27 32 46 68 80 87 98 27 32 46 76 79 80 98 27 32 54 68 79 80 98 27 32 57 65 79 80 98 27 32 57 68 76 80 98 27 32 57 76 79 80 87 27 32 65 68 79 80 87 27 35 43 68 80 87 98 27 35 43 76 79 80 98 27 35 46 65 80 87 98 27 35 54 57 80 87 98 27 35 54 65 79 80 98 27 35 54 68 76 80 98 27 35 54 76 79 80 87 27 35 57 65 76 80 98 27 35 65 68 76 80 87 27 43 46 57 80 87 98 27 43 46 65 79 80 98 27 43 46 68 76 80 98 27 43 46 76 79 80 87 27 43 54 57 79 80 98 27 43 54 68 79 80 87 27 43 57 65 68 80 98 27 43 57 65 79 80 87 27 43 57 68 76 80 87 27 43 65 68 76 79 80 27 46 54 57 76 80 98 27 46 54 65 68 80 98 27 46 54 65 79 80 87 27 46 54 68 76 80 87 27 46 57 65 76 80 87 27 54 57 65 68 80 87 27 54 57 65 76 79 80 32 35 43 46 54 65 76 87 32 35 46 68 79 80 98 32 35 57 68 79 80 87 32 46 57 68 76 79 80 32 65 76 80 87 98 35 43 46 57 79 80 98 35 43 46 68 79 80 87 35 43 57 68 76 79 80 35 46 54 57 68 80 98 35 46 54 57 79 80 87 35 46 54 68 76 79 80 35 46 57 65 68 80 87 35 46 57 65 76 79 80 35 54 57 65 68 79 80 43 46 57 65 68 79 80 43 54 76 80 87 98

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

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions