Skip to main content

Algorithms · Divide-and-conquer algorithms

Using only comparisons, return both minimum and maximum among n≥1 distinct keys

Problem

Using only comparisons, return both minimum and maximum among \(n\ge1\) distinct keys. 1. Give the pairwise algorithm for odd and even \(n\). 2. Prove exactly \(\lceil3n/2\rceil-2\) comparisons. 3. Prove a matching worst-case lower bound, including odd \(n\). 4. Trace \([9,2,7,1,6,3,8]\).

Hint

** One within-pair comparison assigns separate minimum and maximum candidates.

Check your work

Work the problem yourself first. Then open it in Training to check your answer and read the full worked solution.

The answer check and full solution for this problem come with ProofAnvil Practice membership ($19 USD monthly). See membership. Or start with the free Algorithms sample problem: Try the free sample problem.

More Algorithms practice problems

Back to Algorithms

An original ProofAnvil practice problem, written for this course. ProofAnvil is a practice course, not a homework-answer service.