-5
int f(int n)
{
   int x;
   if(n==0)
      x=1;
   else
     x=f(n-1)*2;
   g(x);
   return x;
}
void g(int m)
{
    int y;
    for(y=m;y>0;y/=2);
}

please say running time of the program with Recuurance relation. Thanks in advance

2 Answers2

1

Approximately,

G(m) = lg(m)

and

F(1) = c
F(n) = F(n-1) + G(f(n)) = F(n-1) + n.

because f(n) = 2^n.

Yves Daoust
  • 48,767
  • 8
  • 39
  • 84
0

It depends on your computer (and other things).

You could time the program yourself: on windows

or with time on unix like systems.

Lasersköld
  • 996
  • 5
  • 10