Sorting Algorithms
https://www.bigocheatsheet.com/
Summary
- Selection Sort
- Find the smallest and swap with the first
- Runtime for best, average and worst-case:
- Insertion Sort
- Find where element goes and shift the rest to make room for element
- Runtime for best case is and for average and worst case:
- Works well for almost sorted array
- Merge Sort
- Divide and Conquer - Split into halves, recurse, then merge
- Runtime for best, average and worst-case:
- Does not use temp array
- Linear Search
- Scan one by one until found
Lower Bounds for Sorting
What we have seen in CS240 - Data Structure and Data Management: