Ternary Search
Split into thirds with two probes. Useful for unimodal functions, not faster than binary search on arrays.
Search Variants: Ternary search: two probes, a third kept
38 sits between 12 and 72, so it can only be in the middle third: low becomes 4 and high becomes 7.
Cost
- Best
- O(1)
- Average
- O(log n)
- Worst
- O(log n)
- Space
- O(1)
More comparisons per step than binary search.
Before this
Taught by the same lesson
Search Variants covers these too, in the same run.