Skip to content
Official PYQ · 1991

GATE CS 1991 Q01 — Searching, Sorting, Hashing

Explain with AI
The minimum number of comparisons required to sort 55 elements is ______
View worked solution

Answer: 7

To find the minimum number of comparisons required to sort nn 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 hh has at most 2h2^h leaves. Since there are n!n! possible permutations of nn elements, the decision tree must have at least n!n! leaves to correctly sort all possible inputs.

Therefore, the minimum height hh (which represents the minimum number of comparisons in the worst case) must satisfy:

2h≥n!  ⟹  h≥⌈log⁡2(n!)⌉2^h \ge n! \implies h \ge \lceil \log_2(n!) \rceil

For n=5n = 5 elements:

5!=1205! = 120h≥⌈log⁡2(120)⌉h \ge \lceil \log_2(120) \rceil

Since 26=642^6 = 64 and 27=1282^7 = 128:

6<log⁡2(120)<7  ⟹  ⌈log⁡2(120)⌉=76 < \log_2(120) < 7 \implies \lceil \log_2(120) \rceil = 7

Thus, at least 77 comparisons are theoretically required. This lower bound is tight, as the Ford-Johnson algorithm (merge-insertion sort) can sort 55 elements using exactly 77 comparisons in the worst case.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Searching, Sorting, Hashing questions