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 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 ๏(๐
3
) and the optimal algorithm is ๏(๐). 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 ๐(๐
2
๐๐๐ ๐). 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.

