Bubble Sort Algorithm in C

 
/* Sorts list using bubble sort. Adjacent elements
   are compared and exchanged until list is
   completely ordered.
*/
void bubbleSort(int list[], int n)
{
   int cur, j, temp;
   for (cur = 0; cur <= n; cur++){
      for ( j = n; j > cur; j--)
         if(list[j ] < list[ j - 1]){
            temp = list[ j ];
            list[ j ] = list[ j – 1];
            list[ j -1] = temp;
         }
   }
   return;
}
Creative Commons License Valid CSS Valid XHTML 1.0 Driven by DokuWiki Powered by PHP Powered by Apache get firefox!! kgareth.com Recent changes RSS feed