Binary Search is used to make the searching faster. The internal table does need to be sorted according to the specified search key(s) before performing the binary search.
sort i_mara by matnr descending ersda descending.
read table i_mara with key matnr = condition 1
ersda = condition 2
binary search.
- Standard tables are searched in a linear fashion.
- Sorted tables are sorted in a binary fashion if the specified search key is an initial part of the primary table key or includes this key; otherwise the search is linear.
- The hash algorithm is used for hashed tables if the specified search key is an initial part of the primary table key or includes this key; otherwise the search is linear.
How binary search is performed?
In computer science, binary search, also known as half-interval search[1] or logarithmic search,[2] is a search algorithm that finds the position of a target value within a sorted array.[3][4] It compares the target value to the middle element of the array; if they are unequal, the half in which the target cannot lie is eliminated and the search continues on the remaining half until it is successful.
No comments:
Post a Comment