Starting from:

$29

Pair Product Assignment

1 Programming Assignment
The assignment is to design and implement an algorithm for the PairProduct225 problem. The
problem is defined as follows:
Input: An array A of n non-negative integers.
Output: A boolean value (true or false). If there exists a pair in A that multiplies
to 225, the output will be true. Otherwise, the output will be false.
A Java template has been provided containing an empty function PairProduct225, which takes
an integer array A as its only argument, and returns a boolean value. Your task is to write the
body of the PairProduct225 function. You may assume that the input array A will always conform
to the specification 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 implementation inside the PairProduct225 function in the template. You may not change the name,
return type or parameters of the PairProduct225 function. The main function in the template
contains code to help you test your implementation by entering test data or reading it from a file.
You may modify the main function, but only the contents of the PairProduct225 function will be
marked, since the main function will be deleted before marking begins. Please read through the
comments in the template file before starting.
2 Examples
The table below shows the correct output of the PairProduct225 function on various test inputs.
In cases where the output is true, the pair is given.
Input Array Result Pair
0, 45, 5, 225 true (5,45)
1, 2, 3, 70 false N/A
4, 100, 9, 25 true (9,25)
85 false N/A
15, 45, 60, 15 true (15,15)
13 Test Datasets
A set of input files containing test data are available under the ’Data’ tab on conneX, sorted by
their size and whether or not they contain a pair. 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 20, 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 PairProduct225 problem, with a variety of
running times. For an input array containing n values, the simplest algorithm is Θ(n2) 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 different sizes. The
table below shows the expectations associated with different scores.
Score Description
0 - 5 Submission does not compile or does not conform to the provided
template.
5 - 10 The implemented algorithm is O(n2) or is substantially inaccurate
on the tested inputs.
11 - 16 The implemented algorithm is O(n 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.
17 - 20 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 5 out of 20. The best way to
make sure your submission is correct is to download it from conneX after submitting and test it

More products