I have a project where I should write the following algorithm :
Let an integer function $f\colon\{1,2,3,\ldots,n\} \to \mathbb{Z}$ be monotone and suppose that $f(1) > 0$ and $f(n) < 0$. We would like to find the smallest integer $i$ with $f(i) < 0$. Design an algorithm for this purpose that run in time $O(\log n)4.
I tried to search in the middle ($\frac{n+1}2$) and then go in the right half or in the left half (like binary search) but the input is not sorted. Could someone give me an idea of how I can continue?