Question: Given a unordered list of elements, find both the maximum element and the minimum element. Obvious solution: Consider first element to be max Consider first

Given a unordered list of elements, find both the maximum element and the minimum element.

Obvious solution:

Consider first element to be max

Consider first element to be min

Scan linearly from 2nd to last, and update if something larger then max or if something smaller than min

Write a recursive function that solves this using divide and conquer.

Prototype: void maxmin (list, first, last, max, min);

Base case(s)? Subproblems? How to combine results?

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!