An interactive, visual explorer for binary and n-ary tree traversal algorithms, designed for A-Level Computer Science students and anyone learning tree traversals for the first time.
π Live demo β
- Three traversal algorithms β Pre-order (Root, L, R), In-order (L, Root, R), Post-order (L, R, Root)
- Animated step-by-step playback with adjustable speed
- Manual stepping β click once to advance one step, hold to auto-step at the current speed
- Configurable tree β set min/max depth and min/max children per node; regenerate instantly with the β» button
- Live code panel β syntax-highlighted pseudocode in JavaScript, Python, or C#, with the active line highlighted as the traversal runs
- Call stack panel β real-time call stack visualisation showing recursive calls and their return values
- Sequence bar β the visited node sequence builds up as the traversal progresses
- Dark / light theme toggle
- Resizable panels β drag the dividers to customise the layout; hide the Code or Call Stack panels independently
You can customise the initial state of the application using URL parameters. This is useful for creating shareable links with specific configurations.
langβ Set the initial language (e.g.,?lang=python).categoriesβ Filter the language dropdown to show only languages matching the specified categories (comma-separated, e.g.,?categories=AQA,OCR).settingsβ Toggle the visibility of the settings (left) panel (trueorfalse).codeβ Toggle the visibility of the code panel (trueorfalse).callStackβ Toggle the visibility of the call stack panel (trueorfalse).sequenceβ Toggle the visibility of the sequence bar (trueorfalse).traceLineβ Toggle the code line tracing (trueorfalse).focusβ Toggle focus mode, hiding boilerplate code (trueorfalse).
No build step is required β this is a plain HTML/CSS/JS application.
git clone https://github.com/DevDecoder/tree-traversals.git
cd tree-traversals
npx serve .Then open http://localhost:3000 in your browser.
git clone https://github.com/DevDecoder/tree-traversals.git
cd tree-traversals
python3 -m http.server 8080Then open http://localhost:8080.
Install the Live Server extension, open the repo folder, and click Go Live in the status bar.
Note: The app uses ES modules (
type="module"), so it must be served over HTTP β openingindex.htmldirectly as afile://URL will not work.
tree-traversals/
βββ index.html # Application shell
βββ styles.css # All styling
βββ languages/ # Language template specifications (.lang files)
βββ docs/ # Documentation
βββ src/
βββ main.js # Entry point
βββ ui.js # UI controller β event handling, panel visibility, animation loop
βββ tree.js # Tree data structure and SVG renderer
βββ traversal.js # Generator-based traversal algorithms and Animator class
The repository includes a GitHub Actions workflow (.github/workflows/deploy.yml) that automatically deploys the main branch to GitHub Pages on every push.
To enable it for a fork:
- Go to Settings β Pages in your repository.
- Set Source to GitHub Actions.
- Push any change to
mainβ the workflow will build and deploy automatically.
The live site will be available at https://<your-username>.github.io/<repo-name>/.
We welcome community contributions! The easiest way to get involved is by adding support for new programming languages or pseudocodes.
The application uses a custom, language-agnostic template format (.lang) to build code snippets and logic block highlighting.
- Learn how to add a language: Contributing Guidelines
- Learn how the templating engine works: Language Format Reference