Question

Question 1:

Given the below function. Answer the following questions:

1) [30 points] Calculate its running time T(n)? Show the calculation steps in details (Hint: slide

23 in Chapter: Complexity Analysis)

2)

[20 points] Find the corresponding Big O notation? Justify your answer and show all the details.

void Mystery (int n)

{

int i=n;

while (i>0 )

{

}

printf("Welcome to CE368");

1 /= 2;

int a=0;

for (i=0; i

{

for (int j-n; j>i; j--)

{

a = a + i + j;

}

if (a < 20 )

for (i=1;i<=n; i*=2 )

{

}

else

{

printf("Good work");

a=0;

for (i=n; i>=1; i--)

{

}

a +=i*i;

printf("GoodBye");

Question image 1