[Home]History of Bubble sort/C

HomePage | Recent Changes | Preferences

Revision 3 . . December 14, 2001 7:55 am by Lee Daniel Crocker [I don't see any need for a separate page here.]
Revision 2 . . (edit) October 30, 2001 6:07 am by (logged).161.187.xxx [Changed "int * array" to "int *array".]
  

Difference (from prior major revision) (no other diffs)

Removed: 1d0
A simple C bubblesort implementation for an array of integers:

Removed: 3,16d1

void bubbleSort(int *array, int length)
{
int i, j;
for(i = length - 1; i > 0; i--)
for(j = 0; j < i; j++)
if(array[j] > array[j+1]) /* compare neighboring elements */
{
int temp = array[j]; /* swap array[j] and array[j+1] */
array[j] = array[j+1];
array[j+1] = temp;
}
}


HomePage | Recent Changes | Preferences
Search: