# Assignment 1 programming Part Solution

\$30.00 \$27.90

Category:

## Description

1 Programming Assignment

The assignment is to design and implement an algorithm for the TripleSum225 problem. The problem is defined as follows:

Input: An array of non-negative integers.

Output: A boolean value (true or false). If there are three indices , , such that 0 â‰¤ , , â‰¤ âˆ’ 1 and [ ] + [ ] + [ ] = 225, the output will be true. If no such indices exist, the output will be false. Note that , and do not have to be distinct.

Your task is to write a java program, stored in a file named TripleSum.java, that contains a function TripleSum225, which takes an integer array as its only argument, and returns a boolean value. You may assume that the provided array conforms to the specification above (that is, will contain only non-negative integers).

The main function in your code should help you test your implementation by getting test data or reading it from a file. It should also handle errors and keep track and report running times to the user. You may use the Java template provided for your Lab 2 implementation as a starting point, just be sure that it properly works for your code.

2 Example

The table below shows the correct output of the TripleSum225 function on various test inputs. In cases where the output is true, a set of three elements of the array which sum to 225 is shown. Note that there may be more than one triple of elements which sum to 225.

 Input Array Result Triple 50, 100, 75, 500 true 50+75+100=225 false 150, 125, 100, 175 false (none) 1, 200, 100, 225 (none) true 75+75+75=225 50, 25, 75 false 225, 500, 1000 true (none) 225, 0, 1, 5000 false 0+0+225=225 224, 1, 2, 2, 2 true (none) 224, 1, 0, 2, 2 0+1+224=225

3 Test Datasets

A set of input files containing test data are available in the â€˜Assignmentsâ€™ folder under the â€˜Resourcesâ€™ tab on ConneX, sorted by their size and whether or not they contain a triple which adds to 225. You should ensure that your implementation gives the correct answer on these test files before submitting. It may also be helpful to test your implementation on a variety of other inputs, since the posted data may not cover all possible cases. Depending on the running time of your algorithm, it may not be able to process some of the larger input files.

4 Evaluation Criteria

The programming assignment will be marked out of 25, based on a combination of automated testing (using large test arrays similar to the ones posted on ConneX) and human inspection. There are several possible algorithms for the TripleSum225 problem, with a variety of running times. For an input array containing values, the simplest algorithm is Q 3 and the optimal algorithm is Q( ). The mark for each submission will be based on both the asymptotic worst-case running time and the ability of the algorithm to handle inputs of different sizes. The table below shows the expectations associated with different scores.

 Score Description 0 â€“ 5 Submission does not compile. 5â€“15 The implemented algorithm is tested3 or is inputs. substantially inaccurate on the ( )

15â€“20

20â€“25

The implemented algorithm is ( 7 ). Input arrays of size 10,000 can be processed in under 30 seconds, but arrays of larger sizes may not be feasible in a reasonable amount of time.

The implemented algorithm is ( ), gives the correct answer on all tested inputs, and can process arrays of size 1,000,000 in under 10 seconds.