- Bubble Sort
Exchange two adjacent elements if they are out of order. Repeat until array is sorted. This is a slow algorithm. - Quick Sort
Partition array into two segments. The first segment all elements are less than or equal to the pivot value.
The second segment all elements are greater or equal to the pivot value. Sort the two segments recursively. Quicksort is fastest on average, but sometimes unbalanced partitions can lead to very slow sorting.
- Insertion Sort
Scan successive elements for out of order item, then insert the item in the proper place. Sort small array fast, big
array very slowly.
- Shell Sort
Sort every Nth element in an array using insertion sort. Repeat using smaller N values, until N = 1. On
average, Shellsort is fourth place in speed. Shellsort may sort some distributions slowly.
- Selection Sort
Find the largest element in the array, and put it in the proper place. Repeat until array is sorted. This is also slow.
Sorting Algorithms
最新推荐文章于 2022-07-05 19:42:19 发布