Practice free →
HomeGATE CSEcomputerscienceAlgorithms › If you need a sort that gives a Θ(n log n) worst…

If you need a sort that gives a Θ(n log n) worst-case guarantee AND preserves the order of equal-keyed elements, pick

Aquick sort (in-place and fast in practice)
Bcounting sort (O(n + r))
Cradix sort (O(n × k))
Dmerge sort (Θ(n log n) + stable)
Answer & Solution
Correct answer: D. merge sort (Θ(n log n) + stable)
Merge sort is the only one of these with BOTH a Θ(n log n) worst-case guarantee and stability. Quick sort is fast in practice but has O(n²) worst case and is unstable. Counting and radix have linear time only when keys fit a bounded universe; they are stable but don't give an n log n guarantee on general inputs.
Solve this in the app — GATE CSE practice & 24k+ MCQs →
Related questions