Add RBT and Binary heap#11
Merged
Merged
Conversation
added 3 commits
June 15, 2026 21:00
New src/lib/algorithms/redBlack.js: a Red-Black planner with full insert, delete (transplant + two-child successor copy + the four double-black fix-up cases), and search. It runs the standard CLRS algorithm on a mutable working copy (parent pointers + nil sentinel, ids preserved) and emits a setTree snapshot after each rotation / recolor, so every fix-up step animates. The /bst page gains a tree-type dropdown (BST / Red-Black); switching reseeds the tree. tree-node renders red/black fill with the operation highlight as an outer ring and a fill transition for smooth recoloring; tree-canvas passes the node color; useTreeEditor gains reset(); TreeMenu gains an optional mode dropdown. Home card renamed to "Binary Search Trees".
The recursion-tree builders + recursionActions planner now live in src/lib/algorithms/recursion.js (was app/recursion-tree/fib.jsx), alongside the other action-log planners. Also deletes the unused legacy app/recursion-tree/bst.js.
New /binary-heap segment on the reusable tree component: a min-heap with
insert (sift-up), extract-min (sift-down), build-heap from a typed list
(Floyd O(n) heapify), and heapsort (descending, since it's a min-heap).
src/lib/algorithms/heap.js keeps the heap as an array of {id,value} and
rebuilds a complete binary tree per setTree; sifts swap entries with their ids
so nodes slide past each other on the rAF tween. Reuses binaryLayout and the
existing node states (amber = active pair, green = sorted). Adds a heap-specific
menu and a home card (placeholder image).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR