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
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
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
.
It depends on your computer (and other things).
You could time the program yourself: on windows
or with time
on unix like systems.