Re: Binary Search
- From: "Stefan Meisner" <stefan.meisner@xxxxxxx>
- Date: Tue, 19 Jun 2007 06:26:12 +0200
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
.
- References:
- Re: Binary Search
- From: Stefan Meisner
- Re: Binary Search
- From: John Dough
- Re: Binary Search
- From: Maarten Wiltink
- Re: Binary Search
- From: John Dough
- Re: Binary Search
- From: Maarten Wiltink
- Re: Binary Search
- From: John Dough
- Re: Binary Search
- From: John Dough
- Re: Binary Search
- From: Stefan Meisner
- Re: Binary Search
- From: John Dough
- Re: Binary Search
- From: Stefan Meisner
- Re: Binary Search
- From: John Dough
- Re: Binary Search
- Prev by Date: Re: Binary Search
- Next by Date: Re: Binary Search
- Previous by thread: Re: Binary Search
- Next by thread: Re: Binary Search
- Index(es):