This repository aims to combine all (eventually) sorting algorithms into one piece of code as a quick refresher for beginners and experts. It also measures the time taken by each sorting algorithm function.
To begin with, the following sorting algorithms have already been added, and more can be added.
- Selection Sort - (Average: O(n2), Worst: Average: O(n2))
- Loops through the list while constantly moving the smallest value in the unsorted part to the end of the sorted part.
- https://youtu.be/kPRA0W1kECg?t=0
- Insertion Sort - (Average: O(n2), Worst: Average: O(n2))
- Loops through the list and moves each element value down into the correct location of the currently sorted part.
- https://youtu.be/kPRA0W1kECg?t=10
- Bubble Sort - (Average: O(n2), Worst: Average: O(n2))
- Loops through the list and repeatedly compares adjacent elements and swaps them if needed.
- https://youtu.be/kPRA0W1kECg?t=240
- Quick Sort - (Average: O(nlogn), Worst: Average: O(n2))
- Paritions array into two based off of a pivot index. One holds values less than pivot, the other holds values higher than pivot. Then recursively sorts the two arrays.
- https://youtu.be/kPRA0W1kECg?t=40
On Linux/Mac, use g++ sortOfAllSort.cpp -o sortOfAllSort && .\sortOfAllSort
On Windows, use Visual Studio to run the file. Alternatively, install g++ and use the above command.