Question: Given an array A of N distinct integers sorted in increasing order, we seek an algorithm to determine if there exist two integers in A
Given an array A of N distinct integers sorted in increasing order, we seek an algorithm to determine if there exist two integers in A that sum to k. The algorithm returns TRUE if such a pair exists, and FALSE otherwise.
- Give an exhaustive algorithm and obtain its running time in the worst case. Complete method sum_exh() in file sum.java.
- Give a more efficient recursive algorithm and obtain its running time in the worst case. Complete method sum_rec() in file sum.java.
Submit only file sum.java. Use the main program sum_main.java and input data file sum.in to test your program. Check file sum.out for the correct output
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
