Use the substitution method to show that for the recurrence equation:
T( 1 )=2
T( n )=T(n-1) + 4n
the solution is T( n )= Big Theta( n2 )
Given T( 1 )=2 T( n )=T(n-1) + 4n Solving through substitution method T( n )= T(n-1) + 4n = T(n-2) + 4(n-1) + 4n = T(n-3) + 4(n-2) + 4(n-1) + 4n ...... ...... ...... = T(n-(n-1)) + 4(2) + ... + 4(n-2) + 4(n-1) + 4n = T(1) + 4(2) + ... + 4(n-2) + 4(n-1) + 4n = 2 + 4(2) + ... + 4(n-2) + 4(n-1) + 4n = 4 + 4(2) + ... + 4(n-2) + 4(n-1) + 4n - 2 = 4(1 + 2 + .... + (n-2) + (n-1) + n) - 2
Time complexity = (Largest term by removing constants)
Get Answers For Free
Most questions answered within 1 hours.