38 views

Consider the following program:

void A(int n){
printf("*");
if(n>1){
A(n/4);
A(n/4);
A(n/4);
A(n/4);
}
}

Let $X$ be number of asterisks printed by above function when $n=1024.$ Then the value of $X$ will be ____________

How ans will be $\frac{4^{k+1}-1}{3}$ , where $k=5?$ .

+2

A(1024) = *, A(256), A(256), A(256), A(256) => A(N) = 4 * a(N / 4) +1 where A(1) = 1;

A(4) = 4*1 + 1 = 5, A(16) = 21, A(64) = 85, A(256) = 341, A(1024) = 1365 which is  (4^k+1 -1) /3 with k = 5