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

O(n2)O(n^2)
  • 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

Last updated