The tightest lower bound on the number of comparisons, in the worst case, for…

2004

The tightest lower bound on the number of comparisons, in the worst case, for comparison-based sorting is of the order of

  1. A.

    n

  2. B.

    n2

  3. C.

    n log n

  4. D.

    n log2 n

Attempted by 157 students.

Show answer & explanation

Correct answer: C

Key idea: model any comparison-based sorting algorithm as a binary decision tree and count leaves.

  1. Each internal node of the decision tree is a comparison; each leaf corresponds to one possible output order of the input.

  2. There are n! distinct permutations of n elements, so the tree must have at least n! leaves to produce every possible sorted order.

  3. A binary tree of height h has at most 2^h leaves, so 2^h ≥ n!, hence h ≥ log2(n!).

  4. Using Stirling's approximation (or standard bounds) gives log2(n!) = Θ(n log n).

  5. Therefore the worst-case number of comparisons for any comparison-based sorting algorithm is at least Θ(n log n), i.e., a lower bound of order n log n.

  6. This bound is tight because comparison sorts such as merge sort achieve O(n log n), so the tightest worst-case bound is Θ(n log n).

Explore the full course: Gate Guidance By Sanchit Sir