- Selection sort:
- First, the algorithm finds the smallest item in the array and places it in the front. Then, it finds the second smallest item in the array and places it next to that, and so on. Pretty simple.
- O(n^2) efficiency
- Quicksort:
- A random element is chosen, and then we create two lists: one that contains all elements smaller than the element and one that contains the element and all elements smaller than the element. Then we quicksort those lists, and so on.
- O(n log(n)) efficiency
- Merge sort:
- Merge sort requires a process called "merging", where two arrays are compared to each other to see which value is smaller and then appends it onto a new list. In merge sort, the list is split into each element and merged to each other. Then recursively we run mergesort again.
- O(n log(n)) efficiency
http://puu.sh/5Dbo1.png
As we can see, selection sort sort of tapers off in performance exponentially compared to quicksort and mergesort when we apply it to a larger data set.