Skip to content

feat(searching): Add Ternary Search Algorithm #94

Description

@Sanan507

Overview

Implement Ternary Search in the searching engine. Ternary Search divides a sorted array into three equal segments using two midpoints (mid1, mid2), offering a visual contrast to Binary Search with O(log3 N) time complexity.

Implementation Details & File Reference

  • Algorithm Model: Create backend/src/main/java/com/algorithmrace/visualizer/algorithms/searching/TernarySearchModel.java extending SearchModel.
    • Record frame states with left bound (lo), right bound (hi), mid1, and mid2 highlights per iteration step.
  • Factory Registration: Register "Ternary Search" in SearchingAlgorithmFactory.java.
  • Complexity Catalog: Add entry (O(log3 N) time complexity) in ComplexityCatalog.java.
  • Frontend Metadata: Add entry in frontend/src/data/algorithmMetadata.ts.

Definition of Done

  • Ternary Search appears in the Searching Arena dropdown.
  • Visualizer highlights mid1 and mid2 bounds during search steps.
  • Search metrics accurately record comparison counts.

Skill Level

Medium — requires three-way boundary partitioning and frame state recording.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions