Can someone please help me to solve this problem.
Find a $\theta$ notation for the number of times $x=x+1$ is executed
i=1;
j=0;
while(j<n)do
begin
i=2i+1;
j=j+i;
x=x+1;
end
Can someone please help me to solve this problem.
Find a $\theta$ notation for the number of times $x=x+1$ is executed
i=1;
j=0;
while(j<n)do
begin
i=2i+1;
j=j+i;
x=x+1;
end
Copyright © 2021 JogjaFile Inc.
Trace through the code and see for small $n$. Or even better, just run the code in your programming language of choice. Notice that the number of times will just be equal to the final value of $x$, if you initialize $x$ to 0. Try running it for various values of $n$ and see how it grows.