Question

1, Variation on 3.3#4] Give a big-O estimate in terms of n for the number of oper- ations used in this segment of an algorithm, where an operation is an addition or a multiplication, (ignoring comparisons used to test the conditions in the while loop). while i 〈 n j:= j + i [10 points]

0 0
Add a comment Improve this question Transcribed image text
Answer #1

We all know that Time Complexity of a loop is considered as O(Logn) if the loop variables is divided / multiplied by a constant amount.

Here the loop will stop when i >= n. If we let k be some arbitrary iteration of the loop, the value of i on iteration k will be 4k. The loop stops when 4k > n, which happens when k > log4 n. Therefore, the number of iterations is only O(log n), so the big O estimate in terms of n is O(log n).

Add a comment
Know the answer?
Add Answer to:
1, Variation on 3.3#4] Give a big-O estimate in terms of n for the number of...
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