Skip to content

feat(sort): implement heapsort#3

Merged
gian-gg merged 2 commits intomainfrom
sort/heap-sort
Feb 22, 2026
Merged

feat(sort): implement heapsort#3
gian-gg merged 2 commits intomainfrom
sort/heap-sort

Conversation

@gian-gg
Copy link
Member

@gian-gg gian-gg commented Feb 21, 2026

Description

This PR adds full Heap Sort support to the sorting visualizer and introduces dual visualization modes (bars + tree) for Heap Sort.

Changes included:

  • Added HeapSortPage with step-by-step Heap Sort animation (build max heap + extract max), playback controls, and live comparisons/swaps stats.
  • Added Heap Sort route handling in src/App.tsx.
  • Added/updated the Heap Sort metadata entry in src/algorithms/index.ts and marked it as implemented.
  • Added a view toggle on the Heap Sort page to switch between Bars and Tree visualizations.
  • Added HeapTreeVisualizer for heap-specific tree rendering with per-step node highlighting.
  • Added reusable tree visualization components under src/components/algorithm/tree/ so other tree/heap algorithms can reuse the same primitives:
    • ArrayBinaryTreeCanvas (array-indexed binary tree layout + edge rendering)
    • TreeArrayStrip (array representation strip synced with node state)
    • shared tree types/exports (types.ts, index.ts)
  • Updated SortingVisualizer header layout to better handle longer step descriptions.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have checked that my commit message follows conventional commits

Preview

Bars

heap-bars.mov

Tree

heap-tree.mov

@gian-gg gian-gg changed the title Sort/heap sort feat(sort): add heapsort Feb 21, 2026
@gian-gg gian-gg changed the title feat(sort): add heapsort feat(sort): implement heapsort Feb 21, 2026
@gian-gg gian-gg merged commit 8771296 into main Feb 22, 2026
1 check passed
@gian-gg gian-gg deleted the sort/heap-sort branch February 22, 2026 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant