Reference Document: HW 3.pdf
C(0)=1
C(N)=N2i=0∑N−1C(i))+N
Recursion Tree
graph TB
A((N))-->B((N-1))
A-->C((N-2))
A-->D((...))
A-->E((0))
B-->F((N-2))
B-->G((N-3))
B-->H((...))
B-->I((0))
C-->J((N-3))
C-->K((N-4))
C-->L((...))
C-->M((0))
F-->N((N-3))
F-->O((N-4))
F-->P((...))
F-->Q((0))
General Truncated Tree of the above recursion up to 3 levels and left most branch extended
We can see that a number of branches are being repeated
Brute Force Recursive Solution
Dynamic Programming
Top Down Recursive Solution
C(N)=N2i=0∑N−1C(i))+N
C(N)−N=N2i=0∑N−1C(i))
2N∗(C(N)−N)=i=0∑N−1C(i))
If we have the value of C(N) we can get its previous cumulative values
So say, if we find C(N-1) we can get previous sum from formula and add those values to get sum for C(N)
Bottom Up Iterative Solution