Bubble Sort... which type?
Ok, I'm learning the bubble sort from my textbook, and it looks slightly different than the bubble sorts that I've seen online. Then, I read that there are different types of bubble sorts. However, the book doesn't mention any of this. This is what the book has....
Code:
void bubbleSort(int array[], int elems)
{
int swap, temp;
do{
swap = 0;
for(int count = 0; count < (elems-1); count++)
{
if(array[count] > array[count+1])
{
temp = array[count];
array[count] = array[count+1];
array[count+1] = temp;
swap = 1;
}
}
} while(swap != 0);
}
Can someone tell me which bubble sort this is, and if there is a better or a better way of writing the bubble sort, or is this ok?