Hello guyz. I have 1 trouble here about explanation of Bubble alghorithm. I have some code here and need verbal explanation step by step.
Here is Function of bubblesort:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
void bubblesort(int arr[], int n) {
bool swapped;
for(int i = 0; i < n-1; i++) {
swapped = false;
for( int j = 0; j < n-i-1; j++) {
if(arr[j] > arr[j+1]) {
swap(&arr[j],&arr[j+1]);
swapped = true;
}
}
if (swapped == false)
break;
}
}