Summary:
Sorting
Sorting Type |
Basic operation |
Best case performance |
Expected case
performance |
Worst case performance |
Required Memory space |
Insertion sort |
Insertion |
§Ù(N) |
O(N2) |
O(N2) |
N |
Bubble sort |
swapping |
§Ù(N2) |
O(N2) |
O(N2) |
N |
Selection sort |
swapping |
§Ù(N2) |
O(N2) |
O(N2) |
N |
Quick sort |
Swapping,
partitioning |
§Ù(N
* log N) |
O(N
* log N) |
O(N2) |
N |
Shell sort |
Insertion |
§Ù(N3/2) |
O(N3/2) |
O(N2) |
N |
Merge sort |
merging |
§Ù(N
* log N) |
O(N
* log N) |
O(N
* log N) |
2N |
Heap sort |
selection |
§Ù(N
* log N) |
O(N
* log N) |
O(N
* log N) |
N+pointer |
Radix sort |
distributing |
§Ù(K(N+q)) |
O(K(N+q)), where K= # of digits of a key, and q = # of radix |
O(K(N+q)) |
(N+1)q |
* Recursive
implementation requires additional memory space and computation overhead for
managing a stack.
* comparison
sort – Insertion sort, Bubble sort, Selection sort, Quick sort, Shell sort, ¡¦
non
comparison sort – Radix sort