Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 9: Array processing and Table handling


Comparison between SEARCH and SEARCH ALL

SEARCH (Serial/Linear Search) SEARCH ALL (Binary Search)
It does sequential search It does binary search
Array must have INDEX Array must have INDEX
Not mandatory for array to be in sorted order Array should be in sorted order of searching parameter. It can be sorted using ASCENDING/DESCENDING option of OCCURS clause
Multiple WHEN conditions can be specified Only one WHEN condition can be coded
Condition can’t be compound condition (i.e. you cannot concatenate multiple conditions using AND/OR) Only ‘EQUAL TO’ comparison is possible. Compound condition is allowed
Index should be set to 1 before SEARCH statement Index need not be set to 1
Preferred when:
  • Array size is small
  • Array contains duplicates
  • Array loaded in such way that most frequently accessing element can be loaded in the first few occurrences
Preferred when:-
  • Array size is large
  • Array contains no duplicates
  • Array contains unique key
  • There is no track of frequently accessed elements
Linear search is slower than binary search Faster than serial search
Time take to search element keeps increasing as the number of elements increased when searching through linear process Binary search compresses the searching period by dividing the whole array into half






© copyright mainframebug.com
Privacy Policy