Starting from:
$30

$24

PROGRAMMING ASSIGNMENT #1 Solution




Programming Assignment



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




Input: An array A of n non-negative integers.




Output: A boolean value (true or false). If there exists a triple (i; j; k) in A such that A[i] + A[j] + A[k] = 225, the output will be true. Otherwise, the output will be false. Note that i, j, and k must be distinct.




A Java template has been provided containing an empty function TripleSum225, which takes an integer array A as its only argument, and returns a boolean value. Your task is to write the body of the TripleSum225 function. You may assume that the input array A will always conform to the speci cation above (containing no negative values). Your code is not required to check for incorrectly formed input data.




You must use the provided Java template as the basis of your submission, and put your im-plementation inside the TripleSum225 function in the template. You may not change the name, return type or parameters of the TripleSum225 function. The main function in the template con-tains code to help you test your implementation by entering test data or reading it from a le. You may modify the main function, but only the contents of the TripleSum225 function will be marked, since the main function will be deleted before marking begins. Please read through the comments in the template le before starting.




Examples



The table below shows the correct output of the TripleSum225 function on various test inputs. In cases where the output is true, the triple is given.






Input Array
Result
Triple






10, 45, 12, 203
true
(10,12,203)
1, 2, 3, 70
false
(none)
75, 100, 9, 50
true
(75,100,50)
85
false
(none)
70, 95, 60, 15
true
(70,95,60)
225, 0, 1
false
(none)
225, 0, 0, 1
true
(225,0,0)









Test Datasets



A set of input les containing test data are available under the 'Data' tab on conneX, sorted by their size and whether or not they contain a triple. You should ensure that your implementation gives the correct answer on these test les 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 les.




Evaluation Criteria



The programming assignment will be marked out of 40, 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 n values, the simplest algorithm is (n3) and the optimal algorithm is (n). 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 di erent sizes. The table below shows the expectations associated with di erent scores.




Score
Description




0 - 10
Submission does not compile or does not conform to the provided


template.




11 - 20
The implemented algorithm is O(n3) or is substantially inaccurate


on the tested inputs.




21 - 32
The implemented algorithm is O(n2 log n). Input arrays of size


10000 can be processed in under 30 seconds, but arrays of larger


sizes may not be feasible in a reasonable amount of time.




33 - 40
The implemented algorithm is O(n), gives the correct answer on


all tested inputs, and can process arrays of size 1000000 in under


10 seconds.







To be properly tested, every submission must compile correctly as submitted, and must be based on the provided template. If your submission does not compile for any reason (even trivial mistakes like typos), or was not based on the template, it will receive at most 10 out of 40. 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 con rmation 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.




























































































































































3

More products