Question: Given n distinct integers in an array ( you can assume they are distinct for convenience ) , describe an algo - rithm, that can

Given n distinct integers in an array (you can assume they are distinct for convenience), describe an algo-
rithm, that can find both the maximum and minimum integer using at most 3n/2 comparisons (checking
which out of two numbers is bigger is 1 comparision). You can also assume n is even. Argue why your
algorithm is correct and why it is guaranteed not to need more than 3n/2 comparisons. Note that here we
care about the exact number of comparisons, not just an asymptotic bound on them.

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!