This project demonstrates the high level differences between the sorting algorithms by showing the progression of the data from unsorted to sorted. This project does not intend to compare the speeds of the sorts.
Jump to a sort:
Selection Sort Bubble Sort Insertion Sort QuicksortThis O(N^2) sorting algorithm goes through the list of elements, finds the smallest element, moves it to the front of the list, and then repeats that for the remaning elements of this list. Notice the tick mark. Everything left of the tick mark is already sorted and everything to the right remains to be sorted.
This O(N^2) algorithm goes through the array and swaps 2 adjacent elements if they are in the wrong order. It usually requires multiple passes through the entire array.
This O(N^2) algorithm takes each element of the array (in order, one by one), and places it where it belongs within the already sorted section. Everything left of the tick is already sorted.
This O(N*logN) divide-and-conquer algorithm uses a pivot (underlined in black) and places the pivot in a position such that everything left of the pivot is smaller than the pivot (blue underline), and everything right of the pivot is greater than it (red underline). Then, we repeat that process on the subsection of the array that is left of the pivot, and also on the subsection that is right of the pivot. It uses recursion and works with a smaller section of the entire array during each call.