Skip to content

feat(sorting): Add Tim Sort Hybrid Algorithm #92

Description

@Sanan507

Overview

Implement Tim Sort in the backend sorting engine. Tim Sort is Python's and Java's default standard sorting algorithm — a hybrid of Merge Sort and Insertion Sort — and its inclusion provides learners with insight into production-grade sorting mechanics.

Implementation Details & File Reference

  • Algorithm Model: Create backend/src/main/java/com/algorithmrace/visualizer/algorithms/sorting/TimSortModel.java extending AlgorithmModel.
    • Divide array into small runs (e.g. run size = 32), sort each run using Insertion Sort, then merge runs using Merge Sort while emitting SimulationFrame objects for every comparison and swap.
  • Factory Registration: Add "Tim Sort"TimSortModel mapping in SortingAlgorithmFactory.java.
  • Complexity Catalog: Register complexity metrics (O(N log N) average/worst, O(N) best-case, O(N) space) in ComplexityCatalog.java.
  • Frontend Metadata: Add entry in frontend/src/data/algorithmMetadata.ts with stable: true and inPlace: false.

Definition of Done

  • Tim Sort appears in the Sorting Arena dropdown selector.
  • Runs end-to-end with accurate frame-by-frame step recording.
  • Complexity details render correctly in the Performance Comparison panel and Benchmarks page.

Skill Level

Hard — requires implementing hybrid run-building and run-merging logic with exact frame state tracking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions