Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Efficiency of Sort Algorithms

I am studying up for a pretty important interview tomorrow and there is one thing that I have a great deal of trouble with: Sorting algorithms and BigO efficiencies.

What number is important to know? The best, worst, or average efficiency?

like image 725
MedicineMan Avatar asked Dec 29 '22 15:12

MedicineMan


1 Answers

worst, followed by average. be aware of the real-world impact of the so-called "hidden constants" too - for instance, the classic quicksort algorithm is O(n^2) in the worst case, and O(n log n) on average, whereas mergesort is O(n log n) in the worst case, but quicksort will outperform mergesort in practice.

like image 137
Martin DeMello Avatar answered Jan 24 '23 15:01

Martin DeMello