Re: binary search
- From: Ben Pfaff <blp@xxxxxxxxxxxxxxx>
- Date: Thu, 28 Jul 2005 14:38:01 -0700
alfps@xxxxxxxx (Alf P. Steinbach) writes:
>> but the pay-off is that you can do a binary search trivially,
>> starting at the first item and using simple comparison to find the item
>> quickly, chasing "prev" and "next" pointers at each level.
>
> If the data comes in sorted your procedure will build a degenerate tree,
> which is indeed list-like, and in that case searching is O(n).
We were starting from a sorted linked list. Building a balanced
binary search tree from a sorted linked list is easy. I have a
webpage on how to do it:
http://adtinfo.org/libavl.html/Transforming-a-Vine-into-a-Balanced-BST.html
--
"Writing is easy.
All you do is sit in front of a typewriter and open a vein."
--Walter Smith
.
- References:
- binary search
- From: JD
- Re: binary search
- From: Richard Heathfield
- Re: binary search
- From: Alf P. Steinbach
- binary search
- Prev by Date: Re: binary search
- Next by Date: Re: Are programmers like this in the real world?
- Previous by thread: Re: binary search
- Next by thread: Re: programming job market in bay area in US
- Index(es):
Relevant Pages
|