‎2006 Sep 08 7:53 AM
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.
‎2006 Sep 08 7: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.
‎2006 Sep 08 7:56 AM
‎2006 Sep 08 7: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
‎2006 Sep 08 7: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
‎2006 Sep 08 8: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
‎2006 Sep 08 9: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
‎2006 Sep 08 10:00 AM
‎2006 Sep 08 10: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