Is QuickSort stable?

Boost your GATE General Aptitude and CS Exam readiness with our dynamic quiz. Test your skills with comprehensive questions featuring hints and detailed solutions. Ace your GATE exam confidently!

Multiple Choice

Is QuickSort stable?

Explanation:
Stability is about preserving the original relative order of elements that have equal keys after sorting. QuickSort, in its common in‑place form, uses a partition step that rearranges elements around a chosen pivot by swapping items. This process can move equal-key elements past each other, so their original order isn’t guaranteed to be kept. That’s why QuickSort is not stable in its standard implementation. There are stable QuickSort variants that use extra memory or a different partition approach to preserve order, but the typical, widely taught version is not stable. Hence the conclusion is that QuickSort is not stable.

Stability is about preserving the original relative order of elements that have equal keys after sorting. QuickSort, in its common in‑place form, uses a partition step that rearranges elements around a chosen pivot by swapping items. This process can move equal-key elements past each other, so their original order isn’t guaranteed to be kept. That’s why QuickSort is not stable in its standard implementation.

There are stable QuickSort variants that use extra memory or a different partition approach to preserve order, but the typical, widely taught version is not stable. Hence the conclusion is that QuickSort is not stable.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy