Skip to content

Conversation

@alext04
Copy link

@alext04 alext04 commented Nov 16, 2025

What’s Included

  1. New Algorithm Module: algorithms/TowerOfHanoi.typ

    • Formal algorithm definition for Tower of Hanoi.
    • Mapcode-style specification (rho, F, pi) using a 2D DP table (X[k][p]) to manage the 6 rod permutations.
    • Concrete DP computation for a sample instance (n=2 disks).
    • Visualization of the primary problem's state evolution using the mapcode-viz framework.
  2. New Algorithm Module: algorithms/TreeHeight.typ

    • Formal recursive definition for the height of a binary tree.
    • Mapcode-style specification (rho, F, pi) using a 1D DP table (X[i]) to map node indices to heights.
    • Concrete computation for a sample 5-node tree instance.
    • Full state vector visualization showing the step-by-step height calculation.
  3. Documentation Integration

    • Updated main.typ:
      • Added #include "algorithms/TowerOfHanoi.typ".
      • Added #include "algorithms/TreeHeight.typ".
    • Ensures the new chapters appear in the final output in the correct sequence.

Why This Matters

  • Brings two classic recursive algorithms into the mapcode framework, expanding coverage.
  • Demonstrates two different DP state structures:
    • Tree Height: A 1D DP table for a graph-based dependency.
    • Tower of Hanoi: A 2D DP table (X[k][p]) for a problem with complex, branching sub-dependencies.
  • Serves as excellent templates for future recursive and DP problem additions.

Files Changed

  • algorithms/TowerOfHanoi.typ188 Lines
  • algorithms/TreeHeight.typ168 lines
  • main.typ4 lines added

No existing code modified; additions are isolated and non-breaking.

Checklist

  • Builds successfully
  • Renders correctly in main.typ
  • Follows repository style and structure
  • No backward-incompatible changes
Screenshot 2025-11-16 at 9 19 58 PM Screenshot 2025-11-16 at 9 20 13 PM

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