Optimized bubble sort in JavaScript. Cocktail sort

Bubble sort algorithm doesn’t track the current state of the array.
Even if it gets the fully sorted array as an input, the runtime will remain of the same O(n^2^) complexity. Read more

Similar