Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

internal tables

Former Member
0 Likes
455

what is a binary search ? and how it is useful in a sorted

internal table?

1 ACCEPTED SOLUTION
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
436

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

3 REPLIES 3
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
437

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

Read only

Former Member
0 Likes
436

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

Read only

Former Member
0 Likes
436

Hi

To all gurus helping me out. As iam new to this field.

Thanks&Regards

Suri