Question

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

(a) The best case running time is Θ(n)
(b) The worst case running time is also Θ(n)
(c) If L is already sorted, the the max element is the last element in the list. The function can return L[n-1]. This algorithm is useless as to sort the list it will take O(nlogn) time to sort itself. So total time to find the max element will be O(nlogn).

Add a comment
Know the answer?
Add Answer to:
Consider the following Python function: def find_max (L): max = 0 for x in L: if...
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