简体   繁体   中英

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)

Eg T(n)=T(n-1)+1 has the following pseudocode. Here a =1.

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

And T(n)=2T(n-1)+1 has the following pseudocode. Here 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)). Eg T(n)=0.5T(n-1)+1 is a relation with a =0.5.

I want to ask how exactly can a be smaller than 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 ℕ. 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)

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.

It is clear that that number has to be an integer > 0 for any non-trivial algorithm. In that context, a=0.5 doesn't make any sense - it doesn't correspond to any class of algorithms or pseudocode.

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