- Bubble sort - slowest, worst case and average complexity O(n2)
compare pairs one by one - Selection sort - find the smallest and swap, combination of searching and sorting.
complexity n(n-1)/2 - Insertion sort - worst case O(n2), efficient for small data sets
grow the sorted output list by taking one input at each repetition.
use the smallest O(1) of additional memory space - Quick sort - fastest, also known as partition-exchange sort and is a divide and
conquer algorithm. It divides the list into two and recursively sort the sublists.
complexity in the average case is O(n log(n)) and worst case O(n2) - Merge sort - divide the unsorted array into n partitions of one element and recursively
merge them into sorted list at the end.
It is a fast, stable sorting with guaranteed O(n*log(n)) efficiency but it
requires additional scratch space proportional to the size of the array.
Monday, October 10, 2016
Sorting Algorithms.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment