Re: Binary Search



It's actually a lot faster than what I had imagined at first.
The key, of course, is that it all depends on the number of items
found.

Of course it depends on the number of items found. Anyway, I am still pretty sure, that your idea to do additional recursive binary searches (if one ever does get it to work... I didn't try) would be even slower than this "hybrid" solution.

One interesting is that only one item does match, which we have found using a binary search. In this case we would have 2 comparisions only. The real worse case would be, that all elements do match (as you noticed). In this case we do compare each element. An interesting solution now would be to find the very lower as well as the very upper bound (without collectiong anything) and afterwards collect the elements within those bounds doing a simple loop.
I probably will do this later today or tomorrow and post it here.

---

Viele Grüsse
Stefan Meisner

www.delphi-online.at
Delphi Remoting Components
Delphi Memory Profiler

.