Notes/Advanced Algorithms/Sorting algorithms.md
2024-12-07 21:07:38 +01:00

39 lines
1.0 KiB
Markdown

---
date: 02.09.2024
type: mixed
---
## Sorting algorithms and their [complexity](Complexity.md)
| **Algorithm** | **Time Complexity** |
| ------------- | ------------------------------------------------------------- |
| Selection | $\mathcal{O}(n^2)$ |
| Insertion | $\mathcal{O}(n^2)$ |
| Bubble | $\mathcal{O}(n^2)$ |
| Quick | $\mathcal{O}(n^2)$ worst case, $\mathcal{O}(n\log n)$ average |
| Merge | $\mathcal{O}(n\log n)$ |
| Heap | $\mathcal{O}(n\log n)$ |
### Selection Sort
![Selection sort](Selection-sort-0.png)
![](selection_sort.gif)
### Insertion sort
![](insertion_sort.gif)
### Bubble sort
![](bubble_sort.gif)
### Quick sort
![](quick_sort.gif)
### Merge sort
![](merge_sort.gif)
Cooler visual:
![](Merge-sort.gif)
### Heap sort
![](Heap_sort.gif)