> [!Note] Binary search Pseudocode
>
```pseudo
\begin{algorithm}
\begin{algorithmic}
\Procedure{BinarySearch}{$A[i,...,j], \alpha$}
\If{$i=j$}
\If{$A[i]=\alpha$}
\Return i
\Else
\Return NO
\EndIf
\Elif{$A[(i+j)/2]=\alpha$}
\Return $(i+j)/2$
\Else
\If{$A[(i+j)/2]>\alpha$}
\Return \Call{BinarySearch}{$A[1,...,(i+j)/2], \alpha$}
\Else
\Return \Call{BinarySearch}{$A[(i+j)/2,...,j],\alpha$}
\EndIf
\EndIf
\EndProcedure
\end{algorithmic}
\end{algorithm}
```
# Properties
# Applications
More generally, for all increasing functions $f(i)$ of $i,$ we use binary search to find $i$ so that $f(i)=\lambda.$