2nd November 2019

quora
12

Which is the best sorting algorithm?

The choice of the best sorting algorithm depends on the context.For large inputs, Mergesort, Heapsort and Quicksortare the best algorithms with worst case running time of Mergesort and Heapsort, and the average case running time of Quicksort being O(nlogn).(The worst case of Quicksort which has a running time of O(n^2)

Also, which sort is better quick or merge?

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. If Quick sort is implemented well, it will be around 2-3 times faster than merge sort and heap sort.

Which is the fastest sorting algorithm?

The time complexity of Quicksort is O(n log n) in the best case, O(n log n) in the average case, and O(n^2) in the worst case. But because it has the best performance in the average case for most inputs, Quicksort is generally considered the “fastest” sorting algorithm.

When would you use Quicksort over Mergesort?

Take mergesort over quicksort if you don't know anything about the data. Merge Sort Worst case complexity is O(nlogn) whereas Quick Sort worst case is O(n^2). Merge Sort is a stable sort which means that the same element in an array maintain their original positions with respect to each other.
Write Your Answer

Rate

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

4 / 5 based on 1 vote.

Bookmark

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

Share