Sorting Visualizer

By The Emerald Derp Leader

A sorting algorithm visualizer. It currently has only insertion and selection sort. Automatically repeats when finished.

O(n) is known as time complexity notation. The number inside the round brackets denotes how many checks or swaps are necessary to completely sort the array. The best (general purpose) sorting algorithms are O(n*log(n)), which is almost O(n). The worst are O(n^2). Wikipedia article: https://en.m.wikipedia.org/wiki/Sorting_algorithm

Algorithm explanation:

Selection sort- The simplest of sorts. All it does is look for the smallest item, and put it in the back. Since this item is known to be the smallest, it is ignored next iteration. Always O(n^2) checks, but at most O(n) swaps.

Insertion sort- Also pretty simple. Has an index that moves forward each iteration. Each iteration it checks the front item with the one before it. If the one in front is smaller then it swaps them. This repeats until the one in front isn’t smaller. Worst case O(n^2) swaps and checks, but close O(n) when almost sorted.

Get LowRes Coder to use this program.

Play homegrown retro games and program your own!