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.

  1. Give an exhaustive algorithm and obtain its running time in the worst case. Complete method match_exh() in file match.java.
  2. 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

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!