Does quicksort use more comparisons than merge sort? Why is it faster if it uses more comparisons?
1
Expert's answer
2012-04-03T11:36:38-0400
For each type there are sorting your best / average / worst case. 1) worst case 2) the average case 3) The best case
Merge sort has the properties: 1) NlogN - the elements are taken alternately 2) NlogN - a random array, which is not better or worse 3) NlogN - the array elements are arranged so that at the confluence of sub-arrays are first written elements of the first subarray and then the elements of the second subarray
The bubble sort has the properties: An N ^ 2 - array sorted in reverse order with respect to the desired 2 N ^ 2 - a random array, which is not better or worse 3 N ^ 2 - the array is sorted according to specified criteria / / In the best case, the optimization of H
Therefore it is quicker to judge - it is impossible. At great length arrays show a sort very well. And the same sort on an array of small length is much longer than the usual bubble sort
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment