Sorting Algorithms
Posted codingforum
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Sorting Algorithms相关的知识,希望对你有一定的参考价值。
Reference
[1] https://www.geeksforgeeks.org/stable-quicksort/
Stability
A sorting algorithm is said to be stable if it maintains the relative order of records in the case of equality of keys.
Some sorting algorithms are stable by nature like Insertion sort, Merge Sort, Bubble Sort, etc. And some sorting algorithms are not, like Heap Sort, Quick Sort, etc.
QuickSort is an unstable algorithm because we do swapping of elements according to pivot’s position (without considering their original positions).
If Swap is every expensive, better stability is expected.
以上是关于Sorting Algorithms的主要内容,如果未能解决你的问题,请参考以下文章