View worked solution
Answer: 7
To find the minimum number of comparisons required to sort elements in the worst case, we use the information-theoretic lower bound for comparison-based sorting.
Any comparison-based sorting algorithm can be represented as a binary decision tree. A binary tree of height has at most leaves. Since there are possible permutations of elements, the decision tree must have at least leaves to correctly sort all possible inputs.
Therefore, the minimum height (which represents the minimum number of comparisons in the worst case) must satisfy:
For elements:
Since and :
Thus, at least comparisons are theoretically required. This lower bound is tight, as the Ford-Johnson algorithm (merge-insertion sort) can sort elements using exactly comparisons in the worst case.
Free practice · Your answers on this page are not saved.
