Depending on the data set this additional step could eat away any savings from performing a few steps more in the binary search.
Sorry, but that would only be true if a binary search worked on data with duplicates. It doesn't.
So you have to factor in the additional complexity of the basic search plus the steps required to locate the appropriate (upper or lower) boundary of the run of duplicates.
I don't believe it is possible to code a search over sorted data with duplicates that comes even close to be O(log N). Even in theory. And in practical implementations, it'd be far slower.
Feel free to prove me wrong :)
In reply to Re^3: Modified Binary Search
by BrowserUk
in thread Modified Binary Search
by Limbic~Region
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |