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

Binary Search

Former Member
0 Likes
722

Can anybody tell me,

what is binary search and where can i use it. can i use it on database table or internal tables?

please suggest me

thanks

kp

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
688

hi,

u can use binary search only on Internal table. sorting the table before the binary search opn. is important

7 REPLIES 7
Read only

alex_m
Active Contributor
0 Likes
688

U have to use binary seach in internal table.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
688

You can use it on internal tables with the READ statement and it can greatly increase the performance of the READ statement.

SORT TABLE ITAB ascending by FLD.
READ TABLE ITAB WITH KEY fld = 'SomeVaule' BINARY SEARCH.

REgards.

Rich Heilman

Read only

Former Member
0 Likes
689

hi,

u can use binary search only on Internal table. sorting the table before the binary search opn. is important

Read only

Former Member
0 Likes
688

BINARY SEARCH is used to improve the performance,

It is used on internal tables

SORT ITAB BY NUMBER

READ TABLE ITAB with key number eq '25' BINARY SEARCH.

suppose say ur itab has values from 1,2,3,4 ...................... 50

Now you are searching for 25, What binary search will do is first it will search if 25 is there at top half of 50 values or bottom half,

25 will be at the top half of 50

Read only

gary_king2
Participant
0 Likes
688

Hmmm...

If you don't know what a binary search (sometimes called a Binary chop) is then you really should not be writing ABAP code. Enter this into Google, or see some of Robert Knuth's books on indexing/access methods etc...

Dr Sidewalk

Read only

0 Likes
688

Hi Gary,

do you think that's the right answer???

Regards, Dieter

Read only

gary_king2
Participant
0 Likes
688

Dieter,

1). The question had already been answered within the thread.

2). I gave the response to use Google to find the answer, therefore pointing to an alternative answer and also educating the person at the same time for such future queries.

3). This is supposed to be a technical forum area !!!

4). My statement about knowing what a Binary search is was a bit flippent I agree, but still true.