Question: CSC 225: Spring 2021: Lab 7 PairSum225 algorithm You are to design and implement an algorithm for the PairSum225 problem. The problem is defined as

 CSC 225: Spring 2021: Lab 7 PairSum225 algorithm You are to

CSC 225: Spring 2021: Lab 7 PairSum225 algorithm You are to design and implement an algorithm for the PairSum225 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 are two indices i and such that 0 Stj sn-1 and A[] AD] = 225, the output will be true. If no such indices exist, the output will be false. There are three approaches to solving this problem: 1. The brute-force algorithm can be done in-place where you check every pair of values, A[i] + AV). This algorithm is 0(n). 2. You can choose to sort the array, then scan from left and right through the array at the same time looking for A[i] + AVI 225. This algorithm is O(n logn) provided the sort algorithm is 0 (n logn). 3. Finally, you can solve this problem in O(n) time by using a second array of length 226, (i.c. index range 10,225]). You have been provided with six input test files, three with a pair sum of 225 and three without. Use them to test the correctness of your code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!