Question

In: Computer Science

For the following program fragment, (1) give an analysis of the running time T(n) as a...

For the following program fragment, (1) give an analysis of the running time T(n) as a function of n and (2) give a big-O bound on the asymptotic running time (tight bounds for full credit).

Sum = 0;

for (i=0; i< n; i++)

   for(j=0; j < i*i; j++)

if(j % i == 0)

for (k=0; k<j; k++)

Sum = Sum + 1;

Solutions

Expert Solution

Please follow the below answer.


Related Solutions

For each of the following six program fragments give an analysis of the running time (Big-Oh...
For each of the following six program fragments give an analysis of the running time (Big-Oh will do). (25,very 5 mark) (a)sum = 0; for( i=0; i<n; i++ ) for( j=0; j<n; j++ ) sum++; (b) sum = 0; for( i=0; i<n; i++ ) for( j=0; j<n*n; j++ ) sum++; (c) sum = 0; for( i=0; i<n; i++ ) for( j=0; j<i; j++ ) sum++; (d) sum =0; for( i=1; i<n; i++ ) for( j=1; j<i*i; j++ ) if( j%1...
a) Let T(n) be a running time function defined as T(n) = 3n^2 + 2n +...
a) Let T(n) be a running time function defined as T(n) = 3n^2 + 2n + 5, is this ϴ(n^2 )? Explain prove your answer using the definitions of big-o and omega notations. b) Solve the following recurrence relations using Master theorem. a. ?(?) = 3? ( ?/3 ) + ? b. ?(?) = 5?( ?/2 ) + 2?^2 please help them with both
Give upper and lower bounds for T(n) in the following recurrence: T(n) = 3T(n/4) + n
Give upper and lower bounds for T(n) in the following recurrence: T(n) = 3T(n/4) + n
6. Solve the following recurrence relations t(n) = t(n-1) + 3 for n>1 t(1) = 0...
6. Solve the following recurrence relations t(n) = t(n-1) + 3 for n>1 t(1) = 0 t(n) = t(n-1) + n   for n>1 t(1) = 1 t(n) = 3t(n/2) + n    for n>1, n is a power of 2 t(1) = ½ t(n) = 6t(n-1) – 9t(n-2)   for n>1 t(0) = 0 t(1) = 1
- Solve the following recurrence relation : T(n) = T(αn) + T((1 − α)n) + n
- Solve the following recurrence relation : T(n) = T(αn) + T((1 − α)n) + n
Give asymptotic upper and lower bounds for T(n). Assume that T(n) is constant for n <=...
Give asymptotic upper and lower bounds for T(n). Assume that T(n) is constant for n <= 2. Make your bounds as tight as possible, and justify your answers. T(n) = T(n-2) + n^2
Write a program fragment (not a complete program) which will perform the following task: The int...
Write a program fragment (not a complete program) which will perform the following task: The int variable m currently contains the number of minutes a basketball player played in their last game. Use an IF statement(s) to print out an appropriate message based on the following: If m is from 35 to 48, print the message "very tired" If m is from 10 to 34, print the message "little tired" If m is from 1 to 9, print the message...
What is the recurrence relation for T(n) = (n-1)T(n-1) + n?
What is the recurrence relation for T(n) = (n-1)T(n-1) + n?
Find T(t), N(t), aT, and aN at the given time t for the space curve r(t)....
Find T(t), N(t), aT, and aN at the given time t for the space curve r(t). [Hint: Find a(t), T(t), aT, and aN. Solve for N in the equation a(t)=aTT+aNN. (If an answer is undefined, enter UNDEFINED.) Function    Time r(t)=9ti-tj+(t^2)k t=-1 T(-1)= N(-1)= aT= aN=
What is the running time of QUICKSORT on an array A of length n containing all...
What is the running time of QUICKSORT on an array A of length n containing all the same values? What is the running time if A contains distinct elements sorted in decreasing order? Explain your answers in detail, referring to the source code for PARTITION and QUICKSORT.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT