Question: The following divide-and-conquer algorithm is proposed for finding the simultaneous maximum and minimum: If there is one item, it is the maximum and minimum, and
a. Suppose N is a power of 2. What is the exact number of comparisons used by this algorithm?
b. Suppose N is of the form 3 ∙ 2k. What is the exact number of comparisons used by this algorithm?
c. Modify the algorithm as follows: When N is even, but not divisible by four, split the input into sizes of N/2 − 1 and N/2 + 1. What is the exact number of comparisons used by this algorithm?
Step by Step Solution
3.39 Rating (165 Votes )
There are 3 Steps involved in it
Here is a Java implementation import javautilRandom public class Exercise740 public static int numComparisons public static final int N 1048576 Let N ... View full answer
Get step-by-step solutions from verified subject matter experts
Document Format (1 attachment)
1486-C-S-A(436).docx
120 KBs Word File
