18th November 2019

stackoverflow
11

Which sort is better?

Quicksort is NOT better than mergesort. With O(n^2) (worst case that rarely happens), quicksort is potentially far slower than the O(nlogn) of the merge sort. Quicksort has less overhead, so with small n and slow computers, it is better.

Keeping this in view, why quick sort is best?

Even though quicksort has O(n^2) in worst case, it can be easily avoided with high probability by choosing the right pivot. 1. Its cache performance is higher than other sorting algorithms. This is because, merge sort is stable, so it won't reorder elements that are equal.

Which is the slowest sorting algorithm?

HeapSort: It is the slowest of the sorting algorithms but unlike merge and quick sort it does not require massive recursion or multiple arrays to work. Merge Sort: The merge sort is slightly faster than the heap sort for larger sets, but it requires twice the memory of the heap sort because of the second array.
Write Your Answer

Rate

60% people found this answer useful, click to cast your vote.

3 / 5 based on 2 votes.

Bookmark

Press Ctrl + D to add this site to your favorites!

Share