Question

Calculate the best, worst, and average case complexity functions for linear search and show the complexities...

Calculate the best, worst, and average case complexity functions for linear search and show the complexities in Big-oh notation

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

Best case O(1)

Explanation :- suppose we a list of element {1,5,4,7,8} and we search 1 so at i=0 we found the element that is ist iteration so it is O(1)

Average case O(n)

Explanation :- n*(n+1)/2n=n

So it is O(n)

Worst case O(n)

Explanation :- same list that we above suppose we 8 and 8 exist at at end of list so we traverse 0 to n-1 and each step we compare and we find the at end so it n step

Add a comment
Know the answer?
Add Answer to:
Calculate the best, worst, and average case complexity functions for linear search and show the complexities...
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