write a c function to sort sets of integers with a time stamp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rex41e
    New Member
    • May 2010
    • 2

    write a c function to sort sets of integers with a time stamp

    I'm learning c on my own and I came across this question.
    I'm trying to write a program that sorts a specified number of random sequences of integers.

    I'm using bubble sort but i cant get c to print the average sort time, the maximum sort time and the minimum sort for each sequence number. Thanks in advance.
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    What class are you using to time your results? Are you using the standard time() functions?

    Comment

    • rex41e
      New Member
      • May 2010
      • 2

      #3
      Originally posted by jkmyoung
      What class are you using to time your results? Are you using the standard time() functions?
      http://www.cplusplus.com/reference/clibrary/ctime/
      the problem is i don't even know how to include the time. i dont know what time functions to use with bubble sort. thanks in advance

      Comment

      • jkmyoung
        Recognized Expert Top Contributor
        • Mar 2006
        • 2057

        #4
        Use time() to get the time before you run bubblesort.
        Then after the sort finishes running, use time() again.
        Subtract the 2 times, and display the result.

        eg one way using clock instead of time is shown here: http://bytes.com/topic/c/answers/879...ng-algorithems

        Comment

        Working...