Binary Search to search linearizer table?

Discussion in 'C Programming' started by Andy, Nov 24, 2003.

  1. Andy

    Andy Guest

    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
     
    Andy, Nov 24, 2003
    #1
    1. Advertising

  2. Andy

    Jack Klein Guest

    On 24 Nov 2003 14:04:38 -0800, (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
     
    Jack Klein, Nov 25, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Williams
    Replies:
    2
    Views:
    1,184
    Jacob Yang [MSFT]
    Aug 12, 2003
  2. Timmy
    Replies:
    5
    Views:
    494
  3. Replies:
    9
    Views:
    467
    Keith Thompson
    Jul 3, 2009
  4. sanborne
    Replies:
    5
    Views:
    2,071
  5. Bogdan

    Binary tree search vs Binary search

    Bogdan, Oct 18, 2010, in forum: C Programming
    Replies:
    22
    Views:
    3,241
    Michael Angelo Ravera
    Oct 21, 2010
Loading...

Share This Page