You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expression Tree Visualizer is an interactive Python desktop application for parsing infix expressions, converting them to prefix and postfix notation, building expression trees, and visualizing each stage of the workflow. It is designed for algorithm study, classroom demonstration, and hands-on exploration of how stacks and binary trees cooperate during expression processing.
Operands may be numeric values or symbolic variables, so expressions such as (A+B), x*(y+z), and ((a+4)/(b-2)) can be visualized and traversed alongside purely numeric expressions.
Features
Capability
Description
Expression tree visualization
Render the parsed expression as a binary tree with interactive navigation
Infix → postfix conversion
Convert infix expressions using the Shunting-Yard algorithm
Infix → prefix conversion
Generate prefix notation from the same token stream
Tree traversals
Explore inorder, preorder, and postorder traversals
Work through expressions in a desktop interface built with PySide6
Demo Expressions
Expression
Type
Prefix
Postfix
Evaluation
((3+4)/(9-2))
Numeric
/ + 3 4 - 9 2
3 4 + 9 2 - /
1
(A+B)
Symbolic
+ A B
A B +
Not available
x*(y+z)
Symbolic
* x + y z
x y z + *
Not available
((a+4)/(b-2))
Mixed symbolic
/ + a 4 - b 2
a 4 + b 2 - /
Not available
Architecture
flowchart TD
A[run.py] --> B[app/main.py]
B --> C[ui/main_window.py]
C --> D[ui/expression_input.py]
C --> E[ui/traversal_panel.py]
C --> F[ui/tree_canvas.py]
C --> G[ui/stack_visualizer.py]
D --> H[utils/validators.py]
H --> I[core/tokenizer.py]
H --> J[core/parser.py]
C --> K[core/infix_to_postfix.py]
C --> L[core/infix_to_prefix.py]
C --> M[core/expression_tree.py]
C --> N[core/traversal.py]
C --> O[core/evaluator.py]
K --> P[algorithms/shunting_yard.py]
M --> Q[core/tree_node.py]
Loading
Installation
git clone github.com/tasmaikeni13/expression-tree-visualizer
cd expression-tree-visualizer
python run.py #(pip install -r requirements.txt is optional as it automatically downloads the requirements)
Usage
Launch the application with python run.py.
Enter an infix expression such as ((3+4)/(9-2)) or x*(y+z).
Choose Build Expression Tree for an immediate result or Step-by-Step Animation to replay the algorithm.
Inspect prefix and postfix conversions, then run inorder, preorder, or postorder traversal highlighting.
Review the evaluation panel for numeric expressions, or the symbolic evaluation notice for variable-based expressions.
Algorithms Used
Algorithm
Purpose
Shunting-Yard
Convert infix notation to postfix
Reverse-then-convert prefix generation
Produce prefix notation from infix input
Stack-based tree construction
Build a binary expression tree from postfix tokens
Depth-first traversals
Generate inorder, preorder, and postorder sequences
Main Window — Expression input, conversion output, traversal controls, and tree canvas
Stack Animation — Step-by-step operator stack and output queue updates during conversion
Tree Rendering — Binary expression tree with operator and operand nodes
Applications
Domain
Use Case
Computer science education
Demonstrate stacks, binary trees, and traversals visually
Compiler courses
Explain parsing, notation conversion, and syntax tree structure
Algorithm practice
Observe state changes during classical expression-processing algorithms
Symbolic manipulation study
Visualize algebraic expressions without requiring numeric substitution
License
This project is licensed under the Apache License 2.0 — see the LICENSE file for details.
About
Interactive visualization tool for expression trees that converts infix expressions to prefix/postfix and demonstrates parsing, traversal, and evaluation algorithms.