Question: B. There are many ways to find the maximum element in an array and you have no doubt seen an iterative algorithm for it. The
B. There are many ways to find the maximum element in an array and you have no doubt seen an iterative algorithm for it. The divide-and-conquer approach is to divide an array into two halves (as in merge sort), get the maximum of each half, then compare those two maxima to return the larger.
- Write pseudocode using the book's notation expressing the approach just given
- Implement that algorithm in Java >= 8 or Python >= 3.7. Call the program either DCMaximum.java or dcmaximum.py and write it so that it takes as input a file called numbers.txt. It should print the maximum of the values in that file.
- Write down the recurrence relation that computes the number of comparisons between array elements performed by this algorithm.
- Solve the recurrence relation using the recursion tree method.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
