Previous answer
a) What is the time complexity of the algorithm
First loop run n times
Second loop with inner loop run 1+2+...+n = n*(n+1)/2 times
third loop run n times
So
n + n*(n+1)/2 + n = n^2/2 + 5*n/2 = O(n^2)
Need a fast expert's response?
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Comments
Leave a comment