Question

11. To answer this question, consider the n, consider the following algorithm: for (int i-0; i<ni i++) for (int j = 0; j <= i
b. what is the order (big -o) of this algorithm?
0 0
Add a comment Improve this question Transcribed image text
Answer #1
First for loop is running for i values from 0 to n-1 with an increment of 1


Second for loop is running for j values from 0 to i with an increment of 1

Number of assignments

= \sum_{i=0}^{n}\sum_{j = 0}^{i}1

=1+2+3+..+n

=\frac{n(n+1)}{2}

Time \;complexity=O(n^2)

Note: Please comment below if you have any doubts

Please up vote the solution if it helped. Thanks!

Add a comment
Know the answer?
Add Answer to:
b. what is the order (big -o) of this algorithm? 11. To answer this question, consider...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT