Analyzing Merge Sort 4

Since n cards are handled on each of log2n + 1 passes, the total number of handlings H(n) is:

H(n) = n(log2n + 1)
= nlog2n + n

Since n ≤ nlog2n, then

H(n) nlog2n + nlog2n
2nlog2n

But H(n) ≥ nlog2n, so

nlog2n H(n) 2nlog2n

Thus the time it takes to merge sort n cards is:

Θ(nlog2n)

This can also be expressed without a logarithmic base as:

Θ(nlogn)

since a number's logarithms of different bases differ only by a constant factor (logca = logba × logcb).