Enter how many values you want to sort, then once 'array1' has finished adding all the values, press SPACE to sort the values in 'array2'! Bubble Sort is a simple and comparative sorting algorithm. It selects a value and compares it with the next value in the list. If the next value in the list is greater, it will select the next value in the list and repeat. Else it will continue to swap the selected value in the list until a greater value is found. When a value of equal size is found it will continue to swap the previously selected value. It takes O(n^2) passes on average and worst-case. It takes n passes to bring down one value to the end of the list and n times to do this for all values. Best-Case performance: O(n), if the array is already sorted.
Bubble sort is also called Sinking Sort. Larger values 'sink' to the bottom of the list and smaller values 'float' to the top of the list. It is the simplest of sorting algorithms. It is recommended to keep the array size less than 1000 because bubblesort is slow. For an array containing 100 values, it will take 10 000 passes, but for an array with 1000 values it will take 1 000 000 passes to sort. Although this version runs without screen refresh, bubble sort is still slow in the real world. UPDATES: June 16 -v0.11 released! Added Optimized Bubble Sort(it is now 50% faster) and program will now explain what is happening.