TEC-Bridge Logo

Ternary Search Visualizer

STEM Interactive Visual Learning Program at TEC-Bridge AI

Setup Array

Search Controls

Array Visualization

Algorithm Steps

How to Use

  1. Setup: Enter sorted numbers separated by commas or click "Random Sorted" to generate an array
  2. Search: Enter a number to search for and click "Start Search"
  3. Step Through: Click "Next Step" to see each step of the algorithm execution
  4. Run Through: Click "Run Through" to automatically execute all steps in sequence
  5. Observe: Watch the array elements change colors and algorithm steps highlight on the right
  6. Reset: Click "Reset" to start over with a new search

Colors: Blue = Left, Purple = Right, Orange = Mid1, Pink = Mid2, Green = Found, Red = Excluded

Ternary Search Concept

Ternary Search is a searching algorithm that works on sorted arrays by dividing the search space into three equal parts instead of two.

How it works:

  • Divide sorted array into three equal parts
  • Calculate two midpoints: mid1 and mid2
  • Compare target with values at both midpoints
  • Eliminate two-thirds of search space each iteration
  • Continue until target is found or space is empty
  • More comparisons per iteration than binary search

Time Complexity: O(log₃ n) - theoretically faster than binary search but more comparisons

Ternary Search Code Implementation

Rate This Learning Tool

Clarity of Visualization:
Interactivity:
Educational Value:
Performance:
Intuitivity & Usability:
Overall Evaluation:

© 2025 TEC-Bridge AI. All rights reserved. | Contact: contact@tec-bridge.ai | https://tec-bridge.ai