Question

Problem 1: Let W(n) be the number of times whatsup is printed by Algorithm WHATSUP (see below) on input n. Determine the as

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

a) The j loop prints Whatsup (i+1)^2 times

And i loop runs from 1 to n

Total number of times it prints is W(n)=\sum_{i=1}^{n}(i+1)^2

b) Which equals W (n) = 22 + 32 + . . . (n + 1)2 = (12 + 22 + . . . (n + 1)2)-1

Using the sum of squares formula m(m+1) (2m+1 6 we get

W(n) 6

That is, W(n)- 6

c) In terms of big theta notation, we have W(n) = Θ(n3)

Add a comment
Know the answer?
Add Answer to:
Problem 1: Let W(n) be the number of times "whatsup" is printed by Algorithm WHATSUP (see below) ...
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