Question

g) Func7(n) while (i 5n3) do 10n3 while 3) do s i j return 8 (h) Func8(n) for 1 to n do for i to n2 do for k j to n do s i -t- j return s (i) Func9(n) for i- 1 to n/2 do for j i to i do return s G) Func10 (m) while (i n) do for j 1 to n do i 1 s i+ j return s Find asymptotic running time , find expression for the running time as a function of n, then find valid upper and lower bound which differ by only a constant factor
0 0
Add a comment Improve this question Transcribed image text
Answer #1

(g)

3i = n^2 for outer loop
=> 2log 3n

For outer loop

1 = n^3 / 5i for outer loop
=> 3log 5n

So overall time complexity is O(log 3n3log 5n)

(h)
Outer for loop n times ,
the next for loop n^2 times itself and n times for outer loop so n^3
the next for loop n^3 times itself and n^3 times for outer loop so n^6

Time complexity is O(n6)


(i) Outer loop runs for n/2 time, Inner loop runs for n^2 - n + 1 times.
So overall time complexity is O(n^3)

(j) n times i.e O(n)




Thanks, let me know if there is any concern.

Add a comment
Know the answer?
Add Answer to:
Find asymptotic running time , find expression for the running time as a function of n,...
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