A form of sorting by exchanging that simply interchanges pairs of elements that are out of order in a sequence of passes through the file, until no such pairs exist. The method is not competitive with straight insertion.
Clicking on this step you can see the Create code learningstep of the algorithm.
Everything is awesome!
int i = ;
do {
last_swap_index = 0;
for(int j = ; j <= ; ++j) {
if(a[] > a[]) {
swap(a[], a[]);
last_swap_index = j;
}
}
i = last_swap_index;
} while (last_swap_index > );
You're awesome! No need for help!