Calculator icon

Notation Visualizer

What's an Expression Tree?

Expression Tree

Expression Trees are binary trees whose parent nodes are operators and children nodes are operands of which the operators will execute on. Refer to the Expression Tree Visualizer for the Expression Tree representation of the expression (8 - 2 * 3 + 7).

What's so special about it?

There are three basic ways to traverse binary trees: Preorder, Inorder, and Postorder. Sound familiar? Yup, for expression trees, preorder traversal outputs prefix notation, inorder outputs infix, postorder outputs postfix!

How do these three traversals work?

All these traversals use recursion, which is straightforward for a computer but often difficult for humans to grasp. Hence, I've provided buttons to help you visualize each traversal in action!
Preorder:
  1. Put current node in result
  2. Go to left child, repeat
  3. Go to right child, repeat
Inorder:
  1. Go to left child, repeat
  2. Put current node in result
  3. Go to right child, repeat
Postorder:
  1. Go to left child, repeat
  2. Go to right child, repeat
  3. Put current node in result
Expression Tree Visualizer
it's interactive! (scroll to zoom / drag to pan)!
Result:
[]
Run Visualizer: