% showBinarySearch
for k=1:10
clc
v = sort(ceil(100*rand(1,5)))
x= input('Search for...? '); % search target
L = binarySearch(x, v);

% Check returned value L from binarySearch.
% L is the position AFTER WHICH to insert x if x is not found.
if L~=0 && v(L)==x
fprintf('Found %d at index %d\n', x, L)
else
fprintf('%d not found. Can insert %d after index %d ', x, x, L)
fprintf('to maintain a sorted array.\n')
end
pause
end