Algorithms Optimization – Big O(n log n) and Quicksort Operations

algorithmscomplexityoptimization

I have an Array with 1,000,000 unsorted elements. I need to calculate expected number of operations that needs to be performed to sort array using Quicksort algorithm in common situations (not the n^2 worst case).

I am not sure how (n log n) is calculated – does it even makes sense to calculate this?

If (n log n) = (n*log(some base)n) what base would be for Quicksort?

Best Answer

Before you go on and continue your maths, I would recommend trying to understand big O notation. The notation helps you to have an idea about the evolution of computation costs when input size changes. The base of the log is irrelevant here as it just affects the constant factor

If you need to provide a precise number of operations, you have to analyse the algorithm and the data structure used for its implementation, and not just use a formula.