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

Don't sort internal table before using binary search

0 Likes
836

Dear Experts,

Could you please suggest on below doubt..

If we don't sort internal table before using Binary search what will be the impact on read statement..

Thanks in advance.
2 REPLIES 2
Read only

FredericGirod
Active Contributor
743

if the table is type STANDARD TABLE, and the SORT is not correct, the BINARY SEARCH will give you wrong answer.

It is a dichotomic search: Check in the middle of the list if it is higher or lower than the exepected result. Do it on the result ......

Read only

RaymondGiuseppi
Active Contributor
743

Use a type sorted tables or with sorted secondary table keys (not hashed) definition or a SORT statement, otherwise the behavior will be unpredictable: ‘If this requirement is not met, the correct line is not usually found.’