previous
|
index
|
next
Analyzing Merge Sort 4
Since
n
cards are handled on each of
log
2
n + 1
passes, the total number of handlings
H(n)
is:
H(n)
=
n(log
2
n + 1)
=
nlog
2
n + n
Since
n ≤ nlog
2
n
, then
H(n)
≤
nlog
2
n + nlog
2
n
≤
2nlog
2
n
But
H(n) ≥ nlog
2
n
, so
nlog
2
n
≤
H(n)
≤
2nlog
2
n
Thus the time it takes to merge sort
n
cards is:
Θ(
nlog
2
n
)
previous
|
index
|
next