Question

Why is a forgetful binary search sometimes faster than a normal binary search?

Why is a forgetful binary search sometimes faster than a normal binary search?

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

answer:-A binary search however, cut down your search to half as soon as you find middle of a sorted list. The middle element is looked to check if it is greater than or less than the value to be searched.

Obviously binary search is better than linear search. binary search works in O(logn) and linear search works in O(n). I am not going in technical details as you can find it anywhere. I am just going to give an analogy with daily life scenario so that you can have a good understanding of time complexity .

so that happens in real world application also. suppose you have with trillions of records and you want to search for a particular record so you want to get the result as soon as you enter your query. you don’t want to wait because doing wait is frustrating.

Binary search again —O(logn)+O(nlogn)O(logn)+O(nlogn) for sorting
The basic idea to keep in mind while analyzing huge datasets is that you mostly write only once, but read(or search) often.

Imagine an unsorted array of, say, 10 Million elements and you have to call search() very often.

So in this case, sorting the array once, and using binary search to look up for an entry will be way more efficient than scanning the entire array every single time you call search().

Add a comment
Know the answer?
Add Answer to:
Why is a forgetful binary search sometimes faster than a normal 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