Why Quick Sort Is Better Than Merge Sort???

There are  Many reasons and I have listed some of them below…

  1. Even though Quicksort has O(n^2) in worst case, it can be easily avoided with high probability by choosing the right pivot. By choosing random pivot variable We can get O(nlogn) behaviour   in 99% cases..
  2. If Quick sort is implemented well, it will be around 2-3 times faster than merge sort and heap sort. This is mainly because that the operations in the innermost loop  are simpler.

3.Quick sort is in-place sorting algorithm where as merge sort is not in-place. In-place sorting means, it does not use additional storage space to perform sorting. In merge sort, to merge the sorted arrays it requires a temporary array and hence it is not in-place.

  1. Its cache performance is higher than other sorting algorithms. This is because of its in-place characteristic.

  2. The biggest advantage is locality of reference. Quicksort accesses continuos elements and thus is better in virtual memory elements as compared to mergesort which accesses distant elements in the merge routine.

Leave a comment