CPKit
v1.6.1

Ternary Search

SearchingMedium

Divide search bounds into three parts to isolate targets or unimodal peak boundaries.

Alt+Shift+T

Configuration Panel

Three-way Range Divisions Visualizer

5
0
8
1
12
2
16
3
23
4
38
5
56
6
72
7

Time Complexity

O(log3 N) branching divisions

Space Complexity

O(1) auxiliary variables
Conceptual Overview

Ternary Search divides the search space into three equal segments by evaluating two midpoints (mid1 and mid2) instead of one, running in logarithmic time.

Algorithm Idea

Divide the interval [low, high] into three equal parts. Compare the target to mid1 and mid2 to eliminate 1/3 or 2/3 of the search space.

Stable Sorting

N/A

In-place Memory

N/A

Source: CP-Algorithms search & sorting reference