Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program called Split in Java that reads a text file, in.txt, that contains a list of positive integers (duplicates are possible, zero is

image text in transcribed

Write a program called Split in Java that reads a text file, in.txt, that contains a list of positive integers (duplicates are possible, zero is not considered a positive integer) separated by spaces and/or line breaks. After reading the integers, the program prints out Yes if the set of integers can be split into two subsets with equal sums of elements and with equal numbers of elements. Otherwise (if the list if integers cannot be divided into two subsets satisfying the condition above), the program prints out No. Assume that in.txt contains at least 2 integers. (a) Source code (b) A report (not to exceed two pages) as an ASCI text document, MS Word document, or a PDF file that contains a description of the ALGORITHM implemented by your program and an analysis of its complexity using Big O notation. It is important that you write a description of the algorithm, not a description of your program! In other words, do not explain your classes and methods. Explain: 1 The sequence of operations that you use to solve the problem, and 2) Why this sequence of operations correctly solves the problem. Pseudo-code is a standard way of explaining algorithms. Examples: If in.txt contains 7 7, the program must print out Yes. In this case, the split is (7) and (7). Both sets are of size of 1, and have the same sum of elements. If in.txt contains 5 3 2 4, the program must print out Yes. The split is (2, 5), (3, 4). Both sets have the same size, 2, and the same sum, 7 If in.txt contains 5 7 5 1 1 3, the program must print out Yes. The split is {1, 55) and {1, 3, 7Both sets have three elements and the same sum, 11. If in.txt contains 658344, the program must print out Yes. The split is (4, 5, 6) and (3, 4, 8). Both sets have the same length, 3, and the same sum, 15. If in.txt contains 2 6 10 14 4 8 12 16. There are several splits satisfying the requirement: 12, 8, 10, 16) and (4, 6, 12, 14); (4, 6, 10, 16) and (2, 8, 12, 14); (4, 8, 10, 14) and (2, 6,12,16); (6, 8, 10, 12) and (2, 4, 14, 16). Your program does not need to find all of them. It must stop and print Yes after finding the first split satisfying the requirement

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

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions

Question

6. Identify seven types of hidden histories.

Answered: 1 week ago

Question

What is human nature?

Answered: 1 week ago