Algorithms-and-Data-Structures/OCR-Pseudo-Code/binary_search.ps

16 lines
393 B
PostScript
Raw Normal View History

2024-05-02 20:14:36 +01:00
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