Jump to content

New Experiment Messin With

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
joebenjamin

joebenjamin

    Newbie

  • Members
  • Pip
  • 3 posts
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.....

#2
kkelly

kkelly

    Learning Programmer

  • Members
  • PipPipPip
  • 49 posts
time.h can get you the start and end times of the sort. stdlib.h has a rand() function for generating integers that you can seed with the current time.

#3
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
This post will help you get random numbers:
- http://forum.codecal....html#post23362

Bubble sort should be fairly easy to implement. This will probably help you.

#4
Patrick

Patrick

    Programmer

  • Members
  • PipPipPipPip
  • 101 posts
Thanks a lot Kkelly it's working. I tried it 10 minutes ago. Thanks a lot Void that also gave me a little help for understanding random numbers and counts.

Cheers.