-
Bubble Sort, Qucik Sort
I need to write a program that time a bubble sort and quick sort (sorting 50,000 characters). I have the Bubble sort in the book I have but I don't have the quick sort. Does anyone know where I can find this online or a book I could reference.
Thanks...
-
example for qsort()
Code:
/* qsort example */
#include <stdio.h>
#include <stdlib.h>
int compare (const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}
int main ()
{
int values[] = { 40, 10, 100, 90, 20, 25 };
int * pItem;
int n;
qsort (values, 6, sizeof(int), compare);
for (n=0; n<6; n++)
{
printf ("%d ",values[n]);
}
return 0;
}
http://www.cplusplus.com/ref/cstdlib/qsort.html
-
"where I can find this online" is a classic question which will always get you an answer of "have you tried searching?"
http://cboard.cprogramming.com/search.php?s=
www.google.com
:)