In the worst case, the smallest number of comparisons required by any sorting algorithm, which does only binary comparisons, is
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: B. ⌈log n!⌉
Explanation
A comparison-based sort must be able to distinguish between all n! possible orderings of the input, and each binary comparison can split the remaining possibilities by at most a factor of 2. This information-theoretic argument requires a decision tree of depth at least log₂(n!), so the worst case requires at least ⌈log₂(n!)⌉ comparisons — the well-known lower bound that algorithms like merge sort asymptotically achieve. Hence the correct answer is ⌈log n!⌉.More Data Structures and Algorithms questions
- A problem of size n requires n² bit operations. What is the largest size instance that can be solved in 1 second, if each bit operation is…
- If f(n) = θ(g(n)) and g(n) = O(h(n)), then which of the following is true?
- The number of leaf nodes in a full 4-ary rooted tree of n nodes is
- Which of the following statements maybe false for a decision problem X ∈ NP?
- A binary search tree is obtained by inserting the words "Mathematics", "Physics", "Geography", "Zoology", "Metrology", "Geology", "Psycholo…
- In open addressing, how are collisions typically resolved?