Popular Posts

이은한. Powered by Blogger.

2022년 2월 5일 토요일

stable sorts Vs. unstable sorts


what is difference between stable sorts 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(position 1), 7(position 2), 3(position 3), 4, 7(position 5), 9]
stable sorted list=[3(position 1), 3(position 3), 4, 7(position 2), 7(position 5), 9]
unstable sorted list=[3(position 3), 3(position 1), 4, 7(position 5), 7(position 2), 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

0 개의 댓글:

댓글 쓰기