Why is quick sort and merge sort called stable algorithms?

1 answer

Answer

1176636

2026-08-03 04:45

+ Follow

Quick sort is not stable, but stable versions do exist. This comes at a cost in performance, however.

A stable sort maintains the order of equal elements. That is, equal elements remain in the same order they were input. An unstable sort may change the order. In some cases, the order of equal elements is of no consequence, but when two elements with different values have the same sort key, then order can be important.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.