A ternary search algorithm is for finding the minimum or maximum of a unimodal function.
Let be a unimodal function on some interval . Take any two points and in this segment . Then,
- if , then the required maximum can not be located on the left side, and we need to look only in the interval
- if , similarly we need to pay attention to the segment
- if , then the search should be conducted in
If we chose points as
then the time complexity of this algorithm is