Binary Search to search linearizer table?

A

Andy

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
 
J

Jack Klein

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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top