简体   繁体   中英

Solving the recurrence relation T(n) = n*T(n - 1) + n! (n > 0, T(0) = 2)

Can someone solve the recurrence relation mentioned above and asymptotic time complexity using back substitution? I know the master's theorem way to solve it, but I don't know how to obtain that answer using back substitution.

Just to expand:

T(n) = n*((n-1)*T(n-2) + (n-1)!) + n! =
       n*(n-1)*T(n-2) + n! + n!       =
       n*(n-1)*T(n-2) + 2 * n!        =
       n*(n-1)*((n-2)*T(n-3) + (n-2)!) + 2n! = 
       n*(n-1)*(n-2)*T(n-3) + 3 * n!

By induction, you can prove:

T(n) = n * (n-1) * (n-2) * ... * 3 * T(2) + (n-2) * n!

As we know T(0) = 2 and T(2) = 2 T(1) + 2! = 2 * (T(0) + 1) + 2 = 8 T(2) = 2 T(1) + 2! = 2 * (T(0) + 1) + 2 = 8 :

T(n) = 4 * n! + (n-2) * n! = (n+2) * n! = (n+1)! + n! = \Theta((n+1)!)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM