# Graph Sort

## Visualizing sorting algorithms

This app helps you *see* how a sort algorithm works, step by step.

### Bubble Sort

Bubble Sort is considered one of the least efficient sorting algorithms. All it does is compare each element, one at a time, with every other element, and if that is bigger than the comparison, it swaps them. It has a performance rating of O(n2), meaning that if you have 100 elements, it will take 10,000 (100*100) steps to sort them.

Iteration: 1
Steps: 0
• -6, -42, 9, 87, 180, 149, -11, 109, -46, 113

### Insertion Sort

Insertion Sort is a moderately efficient sorting algorithm. If the data is partially sorted, it can be quite fast. If it is totally random, it can take up to O(n2) but averages O(n1.5). On average, it would take 1,000 - 2,800 passes to sort 100 elements.

Iteration: 1
Steps: 0
• -6, -42, 9, 87, 180, 149, -11, 109, -46, 113

### Quick Sort

QuickSort is one of the most efficient sorting algorithm. It averages O(n * log n). On average, it would take 500 - 1,000 passes to sort 100 elements.

Iteration: 1
Steps: 0
• -6, -42, 9, 87, 180, 149, -11, 109, -46, 113

### Marriage Sort

Marriage Sort is a highly efficient indeterminate sorting algorithm. It is indeterminate because a fully sorted array is never guaranteed. Like real life, elements search, one by one, for "better" (higher valued) elements, stopping once they get a good one and no much better ones are seen over the horizon. At its worse, it is O(n1.5) but it can achieve much better results far faster than even quicksort, independently of how random the elements are. On average, it would take 200 - 700 passes to get a 75% sorted array. Using an algorithm that works well with semi-sorted arrays (such as Insertion Sort) will then provide fully sorted arrays at just over the efficiency of QuickSort. However, Marriage Sort is by far one of the best algorithms yet invented when the number and/or values of elements are dynamic (adding and subtracting).

Iteration: 1
Steps: 0
• -6, -42, 9, 87, 180, 149, -11, 109, -46, 113