Data-structures 2

T(n)=2T(n3)+2==22T(n32)+22+2==23T(n33)+23+22+2==2iT(n3i)+2i+12Base case. i=1T(n)=2iT(n3i)+2i+12=2T(n3)+2Induction step. Let T(n)=2i1T(n3(i1))+2i1+12T(n)=2i1(2T(n3i)+2)+2i1+12=2iT(n3i)+2i+121in3:T(n)=2iT(n3i)+2i+12T(n)=2n/3T(0)+2n/3+12=32n/32T(n)=Θ(2n/3)
T(n)=2T(n2)+nBase case. c1:T(1)c12T(1)O(1)Induction step. Let n<n:T(n)=O(n2)T(n)=2T(n2)+nn22+n2n2n1:T(n)2n2T(n)=O(n)
T(n)=T(n2)+T(n3)+nBase case. c1:T(1)c1Induction step. Let n<n:T(n)=O(n)T(n)=T(n2)+T(n3)+nc12n+c23n+n=(c12+c23+1)nn:T(n)(c12+c23+1)nT(n)=O(n)
0<α<1T(n)=T(αn)+T((1α)n)+nLet n<n:T(n)=O(nlogn)Induction shortcut:T(n)c^αnlog(αn)+c(1α)nlog((1α)n)+n==c^αnlogn+c^αnlogα+c(1α)nlogn+c(1α)nlog(1α)==c1n+c2nlognn2(c1+c2)nlognT(n)=O(nlogn)
T(n)=2T(n)+lognLet m=lognn=2mLet S(m)=T(2m)=T(n)S(m)=2S(m2)+mS(m)=Θ(mlogm)T(n)=Θ(lognloglogn)
T(n)=T(n)+1m=lognn=2mS(m)=S(m2)+1log2(1)=0By master theorem: S(m)=Θ(m0logm)=Θ(logm)T(n)=Θ(loglogn)