Saturday, November 23, 2019
CS sorting analysis essays
CS sorting analysis essays For this lab I tested ten different sorting methods by comparing the time it took to sort ordered, reverse ordered, and random ordered arrays of Integer objects of different sizes. I had to write a Timer class that started the timer before the sorting method was called and stopped the timer when the method was finished sorting the array. The elapsed time was calculated by another method in the Timer class so that the actual run time could be printed once the method completed. My test program contained methods to run all of the sorting methods given the size, type of array (ordered, reverse or random), and the number times to run the sorting method (all entered by the user) before the timer was stopped. For my timing experiment I carried out tests on an array of size 1,000 run 100 times through the method before printing the time (since it would be relatively fast for one iteration), an array of size 10,000 run 10 times, an array of size 25,000 run 1 time, and an array of 50,000 run 1 time. For the arrays of 1,000, 10,000, and 25,000 I did five trials for ordered, reverse, and random arrays to get a good average of the time it took since each run varied slightly. Since the array of 50,000 took a long time to run I conducted only two trials for each size on the three different types of arrays and found the average. The run times are included at the end of this report. I then calculated the time it would take to do one iteration through each of the different sizes for the different types of arrays (i.e I divided the average time it took to run the ordered array of 1,000 100 times by 100 to get the average time it would take to run it once). This data is also available at the en d of this report. The outcome of the experiments proved to be very similar to what was expected. As seen in the many graphs provided one can see that there may or may not be a best case or worse case for each of the sorts. Below are brief descript...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.