Is QuickSort stable?

Prepare for the GATE General Aptitude and CS Test. Enhance your skills with multiple choice questions and detailed explanations. Elevate your readiness and boost your confidence for the exam!

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