Ternary Search Visualizer

0 elements
50%
Not Set
Comparisons: 0
Status: Idle
Found At: N/A

Ternary Search Explained

Ternary Search divides the search space into three parts by calculating two midpoints (mid1 and mid2). It compares the target with these points to narrow down the search to one of three segments, repeating until the target is found or the space is exhausted.

Algorithm Characteristics

  • Time Complexity:O(log₃ n)
  • Space Complexity:O(1) iterative, O(log n) recursive
  • Prerequisite:Array must be sorted
  • Best Use:Sorted arrays or unimodal functions

Key Properties

  • Divides the search space in three parts.

  • Efficient on Uniform Data

  • More complex computation per step

Best suited for medium-sized datasets, requires a sorted array.