OA. free
Free
Micron Data Structures & Algorithms Data Structures & Algorithms Medium

Which one of the statement given in the options is true about the Shell sort?

Micron technical mcq question, verified with a worked answer. Free to practise - no sign-up.

Which one of the statement given in the options is true about the Shell sort?

Choose one option.
Show answer & explanation
Answer: D. O(n^4/3) is the average case time of Shell sort

Shell sort's time complexity depends on the gap sequence used. With an optimal gap sequence (like Knuth's: 3k+1), the average case time complexity is O(n^4/3). The worst case is O(n²) when using a poor gap sequence, and the best case is O(n) when the array is already sorted. Option D correctly identifies the average case complexity.

Step-by-step Derivation:
Shell sort analysis:

  • Best case: O(n) — occurs when the array is already sorted or nearly sorted, requiring only linear comparisons and shifts.
  • Average case: O(n^4/3) — with optimal gap sequences (e.g., Knuth's sequence 1, 4, 13, 40...), empirically shown to be O(n^4/3).
  • Worst case: O(n²) — occurs with suboptimal gap sequences or worst-case input arrangements.

The gap sequence significantly affects performance. Knuth's sequence (3k+1) and other optimized sequences achieve the O(n^4/3) average case. Options A and C claim impossible/wrong complexities. Option B is incorrect because best case is O(n), not O(n^4/3).