procedure binsrch (a: elementlist; x: element; var n,j: integer);
{search the sorted array a[1..n] for x}
initialize lower and upper
begin
while there are more elements do
begin
let a[mid] be the middle element;
case compare (x, a[mid]) of
'>': set lower to mid + 1;
'<': set upper to mid - 1;
'=': found x;
end; {of case }
end; {of while }
not found;
end ;{of binsrch}
![]()