# Question: 5 pts what is the worstcase bigo asymptotic running time...

###### Question details

- [5 pts]: What is the worst-case “big-O” asymptotic running time
of the following method
*mthd*, assuming that the parameter n is a positive integer? Assume that the time complexity of addition is logarithmic in the magnitude of the number. Justify your answer.

void mthd ( int n ) {

int answer = 0;

for ( int i = 1; i <= n; i++ ) {

for ( int k = 1; k <= n; k++ ) {

answer += i + k;

}

}

for ( int m = 1; m < n; m++ ) {

answer += m;

}

}

*Solution:*

- [5 pts]: Consider that
*f(n) = n + n lg n*is Q(n lg n) by applying the definition of Q-complexity from Chapter 3 of Cormen (reproduced below).

Definition: Θ*(g(n))* = { *f(n)* : there exists
positive constants *c _{1}, c_{2},
n_{0}* such that 0 ≤

*c*≤

_{1}g(n)*f(n)*≤

*c*, for

_{2}g(n)*n*≥

*n*}. Find a (c

_{0}_{1}, c

_{2}, n

_{0}) triple that meets the criteria. Show some work.