16 lines
393 B
PostScript
16 lines
393 B
PostScript
function binarySearch(array, searchItem) do
|
|
start = 0
|
|
emd = array.length-1
|
|
mid
|
|
|
|
while (start <= end) do
|
|
mid = (start + emd) / 2
|
|
if (array[mid] > searchItem) do
|
|
emd = mid - 1
|
|
end else if (array[mid] < searchItem) do
|
|
start = mid + 1
|
|
end else do
|
|
return "search item found at index " + mid
|
|
end
|
|
end
|
|
end |