‎2007 Jun 14 9:56 AM
what is a binary search ? and how it is useful in a sorted
internal table?
‎2007 Jun 14 9:59 AM
Hi,
Binay search follows this algorithm.
Its called BINARY coz it devides the list to be searched in to two small lists at each step of the search
suppose you have a table with this data
2 4 5 6 7 8 9 1 3
Now you want to search for 4.
So when you sort the table it will be in this order
1 2 3 4 5 6 7 8 9
So now Binary search divides the table into two
1 2 3 4 5 6 7 8 9
Now 4 is in first list.(6 7 8 9) will be discarded from search
Then again divide into two small lists
1 2 3 4 5
now it is (Discard 1 2 3)
4 5
now again
4 5
Then it finds 4
So every time one half of the list is discarded from the search.
so its fast.
And if your sort it its easy to discard the list .
Regards,
Sesh
Message was edited by:
Seshatalpasai Madala
‎2007 Jun 14 9:59 AM
Hi,
Binay search follows this algorithm.
Its called BINARY coz it devides the list to be searched in to two small lists at each step of the search
suppose you have a table with this data
2 4 5 6 7 8 9 1 3
Now you want to search for 4.
So when you sort the table it will be in this order
1 2 3 4 5 6 7 8 9
So now Binary search divides the table into two
1 2 3 4 5 6 7 8 9
Now 4 is in first list.(6 7 8 9) will be discarded from search
Then again divide into two small lists
1 2 3 4 5
now it is (Discard 1 2 3)
4 5
now again
4 5
Then it finds 4
So every time one half of the list is discarded from the search.
so its fast.
And if your sort it its easy to discard the list .
Regards,
Sesh
Message was edited by:
Seshatalpasai Madala
‎2007 Jun 14 10:04 AM
Hi Suresh
<b>Use of binary search option</b>
When a programmer uses the read command, the table is sequentially searched. This slows down the processing. Instead of this, use the binary search addition. The binary search algorithm helps faster search of a value in an internal table. It is advisable to sort the internal table before doing a binary search. Binary search repeatedly divides the search interval in half. If the value to be searched is less than the item in the middle of the interval, the search is narrowed to the lower half, otherwise the search is narrowed to the upper half.
<u><b>Not Recommended</b></u>
Read table int_fligh with key airln = LF.
<u><b>Recommended</b></u>
Read table int_fligh with key airln = LF binary search.
For internal table check this link
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb35de358411d1829f0000e829fbfe/content.htm
Check this link for binary search
Reward all helpfull answers
Regards
Pavan
‎2007 Jun 15 10:53 AM
Hi
To all gurus helping me out. As iam new to this field.
Thanks&Regards
Suri