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!
Who Can Help Me with My Assignment
There are three certainties in this world: Death, Taxes and Homework Assignments. No matter where you study, and no matter…
How to Finish Assignments When You Can’t
Crunch time is coming, deadlines need to be met, essays need to be submitted, and tests should be studied for.…
How to Effectively Study for a Math Test
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
Comments
Leave a comment