Question: Given an array A of N distinct integers sorted in increasing order, we seek an algorithm to determine if there exists an index i such
Given an array A of N distinct integers sorted in increasing order, we seek an algorithm to determine if there exists an index i such that A[i] = i. The algorithm returns i if such an index i exists, and -1 otherwise.
- Give an exhaustive algorithm and obtain its running time in the worst case. Complete method match_exh() in file match.java.
- Give a divide-and-conquer algorithm and obtain its running time in the worst case. Complete method match_dac() in file match.java.
Submit only file match.java. Use the main program match_main.java and input data file match.in to test your program. Check file match.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
