Data Structures & AlgorithmsHardICPC regional · algorithm theory

Problem: What is the information-theoretic lower bound on comparisons (in the worst case) for sorting 5 distinct elements?

  1. A. 8
  2. B. 6
  3. C. 10
  4. D. 7

Correct answer: D. 7

There are 5! = 120 orders, and each comparison halves the possibilities at best, so at least ceil(log2 120) = 7 comparisons are needed.

More Coding Interview Problems questions

Exams that ask this topic