lo
to 0 and hi
to the last index of the array.lo
is less than hi
:
a. Calculate mid
as the midpoint of lo
and hi
.
b. If mid
is odd, decrement it by 1 to ensure it is even.
c. If the element at mid
is equal to the element at mid + 1
, set lo
to mid + 2
.
d. Otherwise, set hi
to mid
.lo
equals hi
, the element at this index is the single element. Return it.