Question: Example of Program Analysis j = n while ( j >= 1 ) { for ( i = 1; i
Example of Program Analysis
j = n
while ( j >= 1 )
{
for ( i = 1; i <= j; i++ )
x = x + 1;
j = j / 2;
}
1) Determine T(n) where T(n) = the number of times x=x+1 is executed.
2) Determine T(n) for the entire code.
3) What is the asymptotic analysis of 1 and 2?
Note
Geometric Sum:
a + ar1 + ar2 + . + arn = a(rn+1 1)/(r 1), where r != 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
