I'll create an interactive visual experience for teaching Union-Find (Disjoint Set Union) to college CS students. Let me start by exploring the project structure.
Now I'll install framer-motion for smooth animations, then build the full interactive Union-Find teaching experience.
Let me update the title first, then create all the component files.
Now let me create the Union-Find data structure logic:
Now create the tree visualization component with SVG:
Now create the code display component:
Let me fix the unused variables:
Now create the parent array visualization component:
Now create the complexity info component:
Now let me create the main App component that ties everything together:
Let me fix the type errors:
Good, no more type errors. Now let me also fix the CodeDisplay.tsx which had some unused variable patterns:
Now let's also check the ForestVisualization for any issues:
Now update the CSS to have a nice dark theme baseline:
Now let's build the project to check for any errors:
The build succeeds. Let me verify that the ArrayVisualization import is fine too:
The build succeeded — everything compiles cleanly. Let me now review the overall experience to make sure nothing is missing and perhaps add a couple of improvements to make the visualization more polished. Let me quickly review the complete ForestVisualization to ensure edge rendering is correct:
The app is looking great. The build succeeded. Let me do a final review of the complete App.tsx to make sure everything is connected properly:
Everything looks good! The project builds successfully with all components in place. Let me verify the final build one more time:
The project builds successfully! Here's a summary of what I created:
Union-Find Visualizer — Interactive DSU Learning Tool
🏗️ Architecture
src/App.tsx — Main app with 3 tabs: Learn, Playground, and Quiz
src/unionFind.ts — Union-Find data structure with full step-by-step tracking
src/components/ForestVisualization.tsx — SVG-based animated tree/forest visualization
src/components/ArrayVisualization.tsx — Visual parent[] and rank[] array display
src/components/CodeDisplay.tsx — Pseudocode with syntax highlighting and line-by-line tracking
src/components/ComplexityPanel.tsx — Dynamic time complexity display
📖 Learn Tab
- Accordion-style sections covering: What is Union-Find, Parent Array concept, Path Compression, Union by Rank, and Real-world Applications
- Bold keyword highlighting and clear explanations
🎮 Playground Tab (Main Feature)
- 4 pre-built scenarios: Basic Unions, Path Compression demo, Union by Rank demo, Redundant Unions
- Step-by-step playback: Play/pause, forward/back, speed control, progress scrubber
- Live forest visualization: Color-coded trees with animated nodes, directional arrows, glow effects on highlighted elements
- Internal array view: Shows parent[] and rank[] arrays with highlight animations
- Code tracking: Synchronized pseudocode highlighting showing which line is executing
- Custom operations: Execute your own union() and find() operations interactively
- Toggleable optimizations: Enable/disable path compression and union by rank to see the difference
- Complexity panel: Dynamically updates to show time complexity based on enabled optimizations
- Operation log: Running history of all executed operations
🧠 Quiz Tab
- 8 multiple-choice questions covering key Union-Find concepts
- Immediate feedback with detailed explanations
- Score tracking with final results and emoji feedback
Files built: index.html, src/unionFind.ts, src/components/ForestVisualization.tsx, src/components/CodeDisplay.tsx, src/components/ArrayVisualization.tsx, src/components/ComplexityPanel.tsx, src/App.tsx, src/index.css