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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!