Starting from:
$35

$29

Assignment 1 programming Part Solution




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.






To be properly tested, every submission must compile correctly as submitted. If your submission does not compile for any reason (even trivial mistakes like typos), it will receive at most 5 out of 25. The best way to make sure your submission is correct is to download it from ConneX after submitting and test it. You are not permitted to revise your submission after the due date, and late submissions will not be accepted, so you should ensure that you have submitted the correct version of your code before the due date. ConneX will allow you to change your submission before the due date if you notice a mistake. After submitting your assignment, ConneX will automatically send you a confirmation email. If you do not receive such an email, your submission was not received. If you have problems with the submission process, send an email to the instructor before the due date.

More products