On 24 Nov 2003 14:04:38 -0800,
bi*****@hotmail.com (Andy) wrote in
comp.lang.c:
Say given the linearizer table and the key as
tbl[] = {1, 10, 12, 25, 35, 47};
KEY = 1
Can Binary Search be used to find the enclosing segments?
In this case KEY is enclosed by the segments 1 and 10 (items
0 and 1).
Can Binary Search be used in general to find the
enclosing segments for any key in any given table?
TIA
What Binary Search? Searching algorithms are topical in a group like
news:comp.programming.
As far as the standard C library bsearch is concerned, the answer is
no except for the special cases where the key matches one of the
delimiters. If you search for a key of 2 (or 3, or 4, or any number
up to 9), the only result you get is a null pointer. bsearch does not
provide any information on where it gave up.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
ftp://snurse-l.org/pub/acllc-c++/faq