Perhatikan program Pascal berikut ini.
var arr: array [1..20] of integer = (303, 304, 365, 454, 487, 6, 12, 15, 78, 90, 155, 169, 183, 205, 209, 218, 5, 269, 282, 287); function get : integer; var m: integer; left, right: integer; begin if (arr[1] < arr[20]) then get := 1 else begin left := 1; right := 20; while (left < right) do begin m := (left+right) div 2; if (arr[1] <= arr[m]) then left := m+1 else right := m; end; get := left; end; end;