Sorting Algorithm Visualizer

...

Alviz

:

worst-case time complexity:

O(n2)

worst-case space complexity:

O(1)

Left index
Right index
Last index
Unsorted indexes
Sorted indexes
Summary:

leftIndex = 0 and rightIndex = leftIndex + 1 are simultaneously iterated over array. If array[leftIndex] > array[rightIndex] === true at any point during this, then array[leftIndex] and array[leftIndex] are swapped. This continues until the greatest value in the unsorted portion of array is moved all the way to lastIndex (the last index in the unsorted portion of array), after which lastIndex-- occurs. This entire process is repeated till array is fully sorted.