When trying to properly understand Big-O, I am wondering whether it's true that O(n log n)
algorithms are always better than all O(n^2)
algorithms.
Are there any particular situations where O(n^2)
would be better?
I've read multiple times that in sorting for example, a O(n^2)
algorithm like bubble sort can be particularly quick when the data is almost sorted, so would it be quicker than a O(n log n)
algorithm, such as merge sort, in this case?