Skip to content

Add RBT and Binary heap#11

Merged
TamimEhsan merged 3 commits into
masterfrom
tree-base
Jul 6, 2026
Merged

Add RBT and Binary heap#11
TamimEhsan merged 3 commits into
masterfrom
tree-base

Conversation

@TamimEhsan

Copy link
Copy Markdown
Owner

This PR

  • Refactors recursion tree
  • Adds binary heap
  • Adds RBT in BST

TamimEhsan 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).
@TamimEhsan TamimEhsan merged commit 38c4c8f into master Jul 6, 2026
1 check passed
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