Consider the following pseudo-code: Algorithm TestComplexity(A[1..n])
Consider the following pseudo-code:
Algorithm TestComplexity(A[1..n])
1. sum ← 0
2. for i ← 1 to n do
3. for j ← 1 to i do
4. for k ← 1 to j do
5. sum ← sum + 1
6. return sum
What is the asymptotic time complexity of the above algorithm?
Show answerHide answer
Correct answer: (B) O(n³)