Starting from:

$29

Assignment 1 TripleSum225 problem

Assignment 1—programming part
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 nonnegative 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 150 ,125,100,175 false (none) 1 ,200,100,225 false (none) 50,25,75 true 75+75+75=225 225,500,1000 false (none) 225,0,1,5000 true 0+0+225=225 224,1,2,2,2 false (none) 224,1,0,2,2 true 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 𝑂(𝑛3) or is substantially inaccurate on the tested inputs. 15 – 20 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. 20 – 25 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