T(n)=T(2n)=T(4n)+n2, T(1)=Θ(1)
<insert tree>
→ rozmiar
- n2 → n
- (2n)2 → 2n+4n
- (4n)2 → 4n+2⋅16n
- (8n)2 → 4n+2⋅16n
- (4n)2 → 2n+4n
- (8n)2 → 4n+2⋅16n
- (16n)2 → 4n+2⋅16n
Koszt:
- n2
- n2⋅1615
- n2⋅25625=n2⋅(165)2
- n2⋅(165)3
<insert tree>
height=logn+1
2xn=1
x=log2n
mamy ∑j=0∞qj=1−q1 dla ∣q∣<1
T(n)≤∑k=0lognn2⋅(165)k≤n2⋅∑k=0∞(165)k=1116n2
T(n)=O(n2)
∑k=0lognn2⋅(165)k=n2(1116−5⋅(165)logn)=
n2(1116−5⋅nlog165), log(165)=−1.67