Plz tell me where I am wrong in this approach. I am unable to get the correct answer :
T(1) = 8
T(n) = T(n-1) + 6n^2 + 2n
T(n-1) = T(n-2) + 6(n-1)^2 + 2(n-1) ..................
After substitution ,
T(n) = T(n-i) + 6{n^2 + (n-1)^2 + (n-2)^2 + .... + (n-(i+1))^2} + 2{n + (n-1) + (n-2) + .... + (n-(i+1))}
if n-i = 1 => i = n-1
Substitute this in above equation ,
T(n) = T(1) + 6{n^2 + (n-1)^2 + (n-2)^2 + .... + ( n-( (n-1) + 1 ))^2} + 2{n + (n-1) + (n-2) + .... + (n-( (n-1) + 1))}
T(n) = T(1) + 6{n^2 + (n-1)^2 + (n-2)^2 + .... + (0)^2} + 2{n + (n-1) + (n-2) + .... + (0))}
T(n) = 8 + sum of squares upto n terms + sum of natural number upto n terms
This way the term 8 stays in the equation and doesnt go away. Plz help :(