One Pager Cheat Sheet
- In this tutorial, we'll be discussing some important aspects of the
sorting
algorithms, namely Time Complexity, Space Complexity, and Best Suited Scenarios and Data Structures, as well as providing a simulation of Selection Sort, Insertion Sort, Merge Sort and Bubble Sort. - The
selection sort
algorithm is a comparison-based approach with atime complexity
of O(N2), making it best suited for an array data structure with a small, completely unsorted collection. - Insertion sort is an in-place comparison-based sorting algorithm that works best with partially unsorted collections and has a time complexity of O(N2).
- Bubble sort is an inefficient
comparison-based
sorting algorithm that iterates through a collection and swaps adjacent elements, allowing the largest value to"bubble"
up to the top, with Time Complexity O(N2) and Space Complexity O(1). - Merge Sort is a
Divide and Conquer
algorithm that divides an input collection into two portions, recursively calls itself to sort them, and then merges the two sorted portions, with Time Complexity O(NlogN) and Space Complexity O(N), best suited for large, unsorted collections of data.