Not Homwork Fun Project
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.
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.
Any Ideas, I made this one up for fun to also learn how to do arrays and counts.
Any help would be appreciated....
I can add some of what I have done if necessary. Thanks to those who help
# 2 Re: Not Homwork Fun Project
In a second function, I want to sort the second array with an optimized bubble sort.
(My emphasis)
That's an oxymoron.
For precise time computations, with the C programming language, you can compute the difference of two calls to clock() to get the time interval.
http://www.cppreference.com/stddate/clock.html
On Win32 systems, you may use GetTickCount() or timeGetTime() in any language that gives access to system functions.
Be sure that your computations lasts at least a few seconds to get accurate results.
If it doesn't, iterate the sort operation thousands or millions of times so that it lasts enough time.
You may also use a profiler for more detailed profiling.
# 3 Re: Not Homwork Fun Project
I am using \c programming just basic language. I am totally lost and trying to do this for a project for my math class.
Joe benjamin....and this is alos for fun :o)
# 4 Re: Not Homwork Fun Project
I am totally lost and trying to do this for a project for my math class.
So don't say in the thread title that this isn't for homework.
# 5 Re: Not Homwork Fun Project
Questions about the C programming language should be asked on the C++ (non visual C++ issues) forum.
http://www.dev-archive.com/forum/forumdisplay.php?f=9
The clock() function is declared in time.h.
http://www.cppreference.com/stddate/clock.html