|
-
September 24th, 2007, 08:22 PM
#1
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
-
September 25th, 2007, 01:22 AM
#2
Re: Not Homwork Fun Project
What language do you want to use?
-
September 25th, 2007, 03:16 AM
#3
Re: Not Homwork Fun Project
 Originally Posted by joebenjamin
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.
"inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
Club of lovers of the C++ typecasts cute syntax: Only recorded member.
Out of memory happens! Handle it properly!
Say no to g_new()!
-
September 25th, 2007, 09:05 AM
#4
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 )
-
September 25th, 2007, 02:27 PM
#5
Re: Not Homwork Fun Project
 Originally Posted by joebenjamin
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.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
September 25th, 2007, 05:31 PM
#6
Re: Not Homwork Fun Project
Questions about the C programming language should be asked on the C++ (non visual C++ issues) forum.
http://www.codeguru.com/forum/forumdisplay.php?f=9
The clock() function is declared in time.h.
http://www.cppreference.com/stddate/clock.html
"inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
Club of lovers of the C++ typecasts cute syntax: Only recorded member.
Out of memory happens! Handle it properly!
Say no to g_new()!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|