T(2n) copC(2n) 1/2(2n)(2n-1) 2(2n-1) ----- = -------- = ------------- = ------- ≈ 4 T(n) copC(n) 1/2(n)(n-1) n-1
loga( n) = x or ax = n so logb(ax) = logb(n) x logb(a) = logb(n) but x = loga(n) so loga(n) logb(a) = logb(n) or loga(n) = logb(n)/logb(a) let c=1/logb(a) then loga(n) = c logb(n).
SEQUENTIAL-SEARCH(A,K)
- i ← 0
- while i < n and A[i] ≠ K do
- i ← i -1
- if i < n return i
- else return -1
T(n) = [1*p/n + 2 * p/n + ... + n*p/n] + n*(1-p) T(n) = p/n(1 + 2 + 3 + ... + n) +n(1-p) = p/n*(n)(n+1)/2 + n(1-p) (See Page 476) = 1/2 p(n+1) + n(1-p) ≈ n