ass3 - needs to be more comparisons done sine one element...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Ashraf Jerbi Assignment 3 CMPT 225 The graph below shows the runtime for three different sorting algorithms (C++ sort, quicksort and othersort). The x axis represents the number of iterations and teh y axis is the time it took to do that many iterations in seconds. The test was done using test.cpp which generates n random numbers less than one thousand and feeds it to the functions. The test was done 5 times for each sorting algorithm and the average was taken and graphed below. The graphs show some interesting results; it is obvious from the first glance that the quicksort and c++ sort functions are much more efficient than othersort. The reason behind this huge difference is the algorithm used behind the othersort function, in this algorithm there
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: needs to be more comparisons done sine one element is being compared to all the elements in the array. In other algorithms such as quicksort a pivot is choosen and the data is divided into half so fewer items need to be converted thus making it much faster. What seems surprising from this data is the difference between C++ sort and quicksort. As it can be seen from the graph quick sort seems to work better when there are fewer datas to sort, but as soon as the data set gets larger (more than 40,000) the C++ sort seems to become more efficient. And by the time the data number reaches 160,000 the C++ sort is almost twice faster than quicksort....
View Full Document

Page1 / 4

ass3 - needs to be more comparisons done sine one element...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online