Skip to Content
author's profile photo Former Member
Former Member

binary search

Hi

what is the diff b/w

1. read table itab with key city = 'hyderabad'.

2. read table itab with key city = 'hyderabad' binary search.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 08, 2006 at 06:55 AM

    If the addition <b>BINARY SEA</b>RCH is specified, the search is binary instead of linear. This considerably reduces the runtime of the search for larger tables (from approximately 100 entries upwards). For the binary search, the table must be sorted by the specified search key in ascending order. Otherwise the search will not find the correct row.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 08, 2006 at 06:56 AM

    hi,

    the first one is slow in processing.

    it will serach the whole table.

    the second 1 is very faster. i recomment u to use that only.

    it will search by using the INDEX, which is very faster.

    for any clarifiaction pls mail me.

    pls reward points, if this helped u.

    regards,

    anversha.

    anversha.shahul@wipro.com

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 08, 2006 at 06:59 AM

    Hi,

    the statement,

    <b> Read table ... Binary search.</b>

    use binary search logic for reading the table.

    Before using the binary search you must sort the table using field by which you are reading the table and you must sort in ascending order only.

    Rgds,

    Mohan

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 08, 2006 at 07:03 AM

    1 . this search takes lot of time , it searches one by one

    2 . binary search is faster

    suppose say there are 100 records in the internal table and you had written

    read table itab with key city = 'hyderabad' binary search.

    now it splits its search to 50 records and searches for H as Hyderabad starts with H whether it is in top 50 records or bottom 50 records

    if it is in bottom 50 records , then again it will split to 25 each and searches for the next leeter and so on which simplifies the search

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 08, 2006 at 08:33 AM

    hi,

    The prerequisite for 'Binary Search' to read record fastly is that the internal table has to be sorted by the same key with which we are reading the table. Prior to READ statement, if there is no SORT statement with the same key as of read statements' key, Binary Search addition is of no use. It just acts like without binary search.

    Regards,

    Vinny

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 08, 2006 at 09:00 AM

    check this link,to know more about BINARY SEARCH with READ TABLE

    binary-search-function

    Regards

    srikanth

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 08, 2006 at 09:09 AM

    I think the most of them have explained the importance of using binary search as well as pre-requisities and default.

    I would just like to add the algorithm for binary search so that it becomes more clear how the table is read.

    A binary search algorithm (or binary chop) is a technique for finding a particular value in a linear array, by ruling out half of the data at each step, widely but not exclusively used in computer science. A binary search finds the median, makes a comparison to determine whether the desired value comes before or after it, and then searches the remaining half in the same manner. A binary search is an example of a divide and conquer algorithm (more specifically a decrease and conquer algorithm). From the above it is very important to SORT the table otherwise it might be worse than linear search.

    Regards

    Anurag

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.