function search( key : typekey; var r : dataarray ) : integer;
var high, j, low : integer;
begin
low := 0;
high := n;
while high-low > 1 do begin
j := (high+low) div 2;
if key <= r[j].k then high := j
else low := j
end;
if r[high].k = key then search := high {*** found(r[high]) ***}
else search := -1; {*** notfound(key) ***}
end;
|