Description
1 Programming Assignment
The assignment is to design and implement an algorithm for the PairUp225 problem. The problem is defined as follows: Input: An array A of n non-negative integers. Output: A boolean value (true or false). If A can be split into n/2 pairs (x,y) such that x + y = 225, the output will be true. Otherwise, the output will be false. A Java template has been provided containing an empty function PairUp225, which takes an integer array A as its only argument, and returns a boolean value. Your task is to write the body of the PairUp225 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 implmentation inside the PairUp225 function in the template. You may not change the name, return type or parameters of the PairUp225 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 PairUp225 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 PairUp225 function on various test inputs. In cases where the output is true, the set of pairs is given. Input Array Result Pairs 0, 225, 110, 115 true (0,225),(110,115) 150, 125, 100, 175 false N/A 1, 200, 100, 225 false N/A 76, 50, 175, 149 true (76,149),(50,175) 224, 1, 150, 75, 6 false N/A 1,200, 224, 11, 25, 214 true (1,224),(200,25),(11,214) 110 false N/A 110, 115, 110, 115 true (110,115),(110,115)
1
3 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 can be paired up. 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 PairUp225 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 (/20) 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(nlogn). 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. 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.