简体   繁体   English

在递推关系中 a 如何小于 1?

[英]How can a be smaller than 1 in recurrence relations?

The general form of a decreasing recurrence relation is: T(n)=aT(nb)+f(n)递减递推关系的一般形式是: T(n)=aT(nb)+f(n)

Eg T(n)=T(n-1)+1 has the following pseudocode.例如T(n)=T(n-1)+1具有以下伪代码。 Here a =1.这里a = 1。

void rec(num)
{
   if(num>0)
   {
      printf(num);
      rec(num-1);
   }
}

And T(n)=2T(n-1)+1 has the following pseudocode.并且T(n)=2T(n-1)+1具有以下伪代码。 Here a =2.这里a = 2。

void rec(num)
{
   if(num>0)
   {
      printf(num);
      rec(num-1);
      rec(num-1);
   }
}

The Master's theorem for decreasing functions states that if a<1 , T(n)=O(f(n)). Master 的递减函数定理指出,如果 a<1 ,T(n)=O(f(n))。 Eg T(n)=0.5T(n-1)+1 is a relation with a =0.5.例如T(n)=0.5T(n-1)+1是与a =0.5 的关系。

I want to ask how exactly can a be smaller than 1?我想问一下a怎么能小于 1? What is some possible pseudocode for the above relation?上述关系的一些可能的伪代码是什么?

A recurrence relation is just a neat mathematical description of (a class of) functions on ℕ.递归关系只是 ℕ 上 (a class of) 函数的简洁数学描述。 Your example T(n)=0.5T(n-1)+1 is a perfectly valid reccurrence relation that has many solutions, eg T(1) = 1, T(2) = 1.5, T(3) = 1.75, .. , or, in general, T(n) = O(1)您的示例T(n)=0.5T(n-1)+1是一个完全有效的递归关系,它有许多解决方案,例如T(1) = 1, T(2) = 1.5, T(3) = 1.75, .. ,或者,一般来说,T(n) = O(1)

The master theorem uses recurrence relations to describe the runtime of divide-and-conquer algorithms. 主定理使用递归关系来描述分治算法的运行时间。 In that case, a stands for the number of subproblems in which the original problem is divided.在这种情况下, a代表原始问题被划分的子问题的数量。

It is clear that that number has to be an integer > 0 for any non-trivial algorithm.很明显,对于任何重要的算法,该数字必须是 integer > 0。 In that context, a=0.5 doesn't make any sense - it doesn't correspond to any class of algorithms or pseudocode.在这种情况下, a=0.5没有任何意义——它不对应于任何算法或伪代码的 class。

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

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