Sorting
Sorting algorithms aren't usually tested alone. They are often paired with another problem type and the goal is to really see if you're able to think about the algorithms in a wider context
Last updated
Sorting algorithms aren't usually tested alone. They are often paired with another problem type and the goal is to really see if you're able to think about the algorithms in a wider context
Last updated
Traverse from left to right, swap element with neighbor is neighbor is less than element
Repeat till no more swaps are needed
Invariant: after every iteration, the largest elements are arranged at the end in ascending order
If duplicates allowed, use , otherwise, can refer to the partitioning algorithms used in Quick Select
Worst case can be if array already sorted
is the number of distinct elements
Usually best if so the overall runtime could be