stable vs. unstable sorts

Definition

Stable and unstable is depend on how sort any duplicated list.
If the algorithm keeps original position of duplicated values, it is stable sort algorithm
If the algorithm positioned duplicated values randomly, it is unstable sort algorithm

Example

raw list=[3(1), 7(1), 3(2), 4, 7(2), 9]
stable sorted list=[3(1), 3(2), 4, 7(1), 7(2), 9]
unstable sorted list=[3(2), 3(1), 4, 7(2), 7(1), 9]

Stable Sorting

Bubble Sort
Insertion Sort
Merge Sort
Counting Sort
Bucket Sort
Radix Sort

Unstable Sorting

Selection sort
Heap Sort
Shell Sort
Quick Sort

 Share!

 
comments powered by Disqus