quick sort complexity analysis (best case)
As we know Recurrence of quick sort is T(n) =
2T(n/2) + n eq.1
we solve it by Master Method
step1 . compute nlogba
here we compare eq.1 with T(n) = aT(n/b) + f(n)
a = 2 ,b=2 , f(n) = n
nlogba
à nlog22 à n
step2. we compare
function f(n) with nlogba
here from
eq.1
f(n) = n &
nlogba
= n
i.e f(n) and nlogba
are equal
f(n) = θ (nlogba)
so case 2 of Master Method is applied
step3.
T(n) = θ (nlogba.logn) eq.2
put value of nlogba
à nlog22 à n into eq.2
T(n) = θ (nlogn) Answer
No comments:
Post a Comment