Inductive Case: Assume T(k)=21(3k2−k) holds where n=k. Hence, try T(k+1):
T(k+1)=T((k+1)−1)+(3(k+1)−2)=T(k)+3k+3−2=21(3k2−k)+3k+1=21(3k2+5k+2)=21((3k2+6k+3)−(k+1))=21(3(k2+2k+1)−(k+1))=21(3(k+1)2−(k+1)) as required
Correct
Question 4
Consider the following relation:
T(1)T(n)=1=8T(⌈2n⌉)+n3
Prove by induction, that T(n)≥2n3 for all n≥2.
Basis Case:
Let nLHS=T(2)RHS=2n3∴LHS=2=8T(1)+23=8+8=16=2⋅23=16≥RHS as required
Inductive Case: Assume T(m)≥2m3 for all m≤k for some k≥2.
Now substitute n=k+1: ( goal is to show T(n)≥2(k+1)3 )
T(k+1)=8T(⌈2k+1⌉)+(k+1)3≥8⋅2(2k+1)3+(k+1)3=2(k+1)3+(k+1)3=3(k+1)3≥2(k+1)3 as required
> [!success] Correct
>
# Question 5
```python
def f(n):
if n <= 1:
return 1
else:
x = f(math.floor(n / 2))
y = f(math.floor(n / 2))
return g(n, x, y) # runs in linear time O(n)
```