On Mon, 17 Sep 2007 04:18:57 -0400, joebenjamin wrote:
Im tring an experiment that will generate 7000 integer random numbers and
save them in an array. Then I need to copy these 7000 values into a second
array, so that I have two identical integer arrays.
In a function, I want to sort the first array with an un-optimized bubble
sort.
In a second function, I want to sort the second array with an optimized
bubble sort.
Optimized bubble sort?
So in the main, I would like to print out the time each sort routine
took to execute and print out a message determining which sort routine
was faster.
#include <time.h>
int main(void)
{
clock_t start, end;
double t0, t1;
start = clock();
func0(arr0, 7000);
end = clock();
t0 = (double)(end - start) / CLOCKS_PER_SEC;
/* Now t0 is the *processor* time elapsed by func0. Repeat the
* same for func1, compare them, print them, etc. */
return 0;
}
Any Ideas, I made this one up for fun to also learn how to do arrays and
counts.
Is there anybody still taking bubblesort seriously? Isn't it just a
teaching toy? No, I'm told that it predates selection sort and insertion
sort... But I still can't imagine how anybody could come up with something
like that having serious purposes.
--
Army1987 (Replace "NOSPAM" with "email")
If you're sending e-mail from a Windows machine, turn off Microsoft's
stupid “Smart Quotes” feature. This is so you'll avoid sprinkling garbage
characters through your mail. -- Eric S. Raymond and Rick Moen