Question
Python 3

5. (16 points) Determine the big-O running time of each of the following functions: def pi (a) for i in range(len (a)): print
def p2(a): for i in rangeClen(a)): for j in a: print (ati].j) def p3(a): for i in a: for j in a: print (i,j) def p4(a): for i
print (ali-1]) p1 (a) i i*2 def p13(a) for i in range(len(a)*len(a)) print (a[o]) def p14 (a): i-1 while i<len(a): while j<le
0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

a)

Since p1 has 2 loops but not nested both over length.So, it is O(n)

b)

Since p2 has 2 nested loops. So, it is O(n^2)

c)

Since p3 has 2 nested loops. So, it is O(n^2)

d)

Since p4 has 1 loop and calling p1 at every iteration of loop. So, it is O(n^2)

Note: Brother according to HomeworkLib's policy we are only allowed to answer first 4 parts if there are many. So, I request you to post other as separate posts.

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Python 3 5. (16 points) Determine the big-O running time of each of the following functions:...
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