Open In App

Algorithms | InsertionSort | Question 6

What is the best sorting algorithm to use for the elements in array are more than 1 million in general?
(A) Merge sort.

(B) Bubble sort.
(C) Quick sort.
(D) Insertion sort.



Answer: (C)
Explanation: Most practical implementations of Quick Sort use randomized version. The randomized version has expected time complexity of O(nLogn). The worst case is possible in randomized version also, but worst case doesn’t occur for a particular pattern (like sorted array) and randomized Quick Sort works well in practice.

Quick Sort is also a cache friendly sorting algorithm as it has good locality of reference when used for arrays.



Quick Sort is also tail recursive, therefore tail call optimizations is done.
Quiz of this Question

Article Tags :