Consider the problem of computing both the maximum and minimum
values in an array of size
. A naive algorithm will require roughly
comparisons. Here is an alternative strategy: First, recursively sub-divide the
array in two parts and compute the minimum and maximum in each part. Then
compare the results obtained from each part to output the final answer.
Show that the divide and conquer strategy will require roughly
comparisons. Write an imperative program based on the above idea.
You may write the program in any language of your choice. However it may be simplest to complete this Python program template.