Question

Find the best big-O notation to describe the complexity of following algorithms: – A binary search...

Find the best big-O notation to describe the complexity of following algorithms:

– A binary search of n elements

– A linear search to find the smallest number in a list of n numbers

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

Binary search :- a binary search work in the sorted array. The best case complexity is O(1)

Suppose we wnt to search x and that x ia the midlle element of sorted array of n elements then it ia find with ist step only so it ia O(1)

Linear search :- O(n)

In linear search to find smallest elements. Ist we select an element assuming it is smallest now we compare other elements linear update if thete is smallest than previous value selected so if smallest exit at last then it take n step so itbis O(n)

Add a comment
Know the answer?
Add Answer to:
Find the best big-O notation to describe the complexity of following algorithms: – A binary search...
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