Answer to Question #8014 in Java | JSP | JSF for JD

Question #8014
Does quicksort use more comparisons than merge sort? Why is it faster if it uses more comparisons?
Expert's answer
For each type there are sorting your best / average / worst case.
1) worst
2) the average case
3) The best case

Merge sort has the
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

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
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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

New on Blog