简体   繁体   English

通过“ T(n-1)”形式的递归树求解递归关系

[英]Solving Recurrence Relation via Recursion Trees of the Form “T(n-1)”

I understand that the Master Theorem and recursion tree can be used for "divide-and-conquer" recurrence relations (ie T(n)=T(n/2)+1 ). 我知道主定理和递归树可用于“分而治之”递归关系(即T(n)= T(n / 2)+1 )。

However, how would I apply those concepts to T(n)=T(n-1)+logn? 但是,如何将这些概念应用于T(n)= T(n-1)+ logn?

To my understanding, you cannot apply the two concepts to (n-1) decrements. 据我了解,您不能将这两个概念应用于(n-1)个减量。 But the assignment and professor are requiring T(n)=T(n-1)+logn to be solved using recursion trees and master theorem. 但是作业和教授要求使用递归树和主定理求解T(n)= T(n-1)+ logn。

Furthermore, is there any reason that the following is not the recursive expansion for the above function? 此外,是否有任何理由说明以下内容不是上述功能的递归扩展?

T(n)=T(n-3)+log(n-2)+log(n-1)+log(n)

According to my professor, it should not be log(n-2) and log(n-1) but rather 根据我的教授,它不应该是log(n-2)和log(n-1),而应该是

T(n)=T(n-3)+logn+logn+logn

which makes absolutely no sense to me. 这对我来说绝对没有意义。

The following is a subtractive version of the master theorem: 以下是主定理的减法形式:

If T(n) = aT(nc) + g(n) where c>=1 and g(n)=Theta(n^k) for k>=0, then 如果T(n)= aT(nc)+ g(n)其中c> = 1且g(n)= Theta(n ^ k)且k> = 0,则

  • T(n)=Theta(n^k) if a<1 如果a <1,则T(n)= Theta(n ^ k)
  • T(n)=Theta(n^{k+1}) if a=1 如果a = 1,则T(n)= Theta(n ^ {k + 1})
  • T(n)=Theta(a^{n/c}) if a>1 如果a> 1,则T(n)= Theta(a ^ {n / c})

It does not include the particular case you ask, but states a general result on decrements. 它不包括您要求的特殊情况,而是陈述了减量的一般结果。

Two things, 两件事情,

  1. The recursive definition states that you must replace n with n-1 when calling T(n) again, so your logic is sound for T(n)=T(n-3)+log(n-2)+log(n-1)+log(n) . 递归定义指出,再次调用T(n)时必须将n替换为n-1 ,因此对于T(n)=T(n-3)+log(n-2)+log(n-1)+log(n)

  2. Your can easily make the argument that log(1) + log(2) + log(3) + ... log(n) = log(n!) = Theta(nlogn) , and log(n) + log(n) + log(n) ... + log(n) = nlog(n) = Theta(nlog(n)) 您可以轻松地得出log(1) + log(2) + log(3) + ... log(n) = log(n!) = Theta(nlogn)以及log(n) + log(n) + log(n) ... + log(n) = nlog(n) = Theta(nlog(n))

http://en.wikipedia.org/wiki/Factorial#Rate_of_growth_and_approximations_for_large_n http://en.wikipedia.org/wiki/Factorial#Rate_of_growth_and_approximations_for_large_n

http://en.wikipedia.org/wiki/Stirling%27s_approximation http://en.wikipedia.org/wiki/斯特林%27s_approximation

To look at it as a tree, it's actually just a tree with worst case height, ie 要把它看成一棵树,实际上只是一棵最坏情况下的树,即

在此处输入图片说明

This is because at each call, There is only one subproblem to solve. 这是因为在每个调用中,只有一个子问题需要解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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