0
To do a bubble sort you just need to swap two value and to do it until the table is sort: https://en.wikipedia.org/wiki/Bubble_sort An possible implementation of the bubble sort in Java: int n = intArray.length; int temp = 0; for(int i=0; i < n; i++){ for(int j=1; j < (n-i); j++){ if(intArray[j-1] > intArray[j]){ temp = intArray[j-1]; intArray[j-1] = intArray[j]; intArray[j] = temp; } } }
27th Dec 2016, 2:38 PM
Florian Castelain
Florian Castelain - avatar