Question: a)There is a divide-and-conquer algorithm that uses less key constants to simultaneously determine the maximum and the minimum. This uses the following idea: 1. If

a)There is a divide-and-conquer algorithm that uses less key constants a)There is a divide-and-conquer algorithm that uses less key constants to simultaneously to simultaneously determine the maximum and the minimum.

This uses the following idea: 1. If the set has only one element e, then this is at the same time the minimum and the maximum.

2. For a set with two elements (e1 and e2) one can find out with a comparison, which is the minimum and which is the maximum.

3. If the set has more than two elements, divide it recursively into two roughly equal subsets. As a result you get one smallest and one largest element (Min1, Max1, Min2, Max2). From this, 2 comparisons can be used to determine the total maximum and total minimum of the currently considered sublists.

Enter an algorithm in pseudocode that implements this idea.

b)In Java, implement a version of the algorithm from part a) that uses only positions as the transfer parameter, i. it should only be worked on a single list. This makes sense, especially against the background, that this is a search, so it should not be necessary to move elements or copy to find a record. Use a two-element int array with the maximum and minimum as the return type.

1-2 3n

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!