Mathematical expressions can be represented as binary trees. For example, (1 + 2) can be represented with a peak node "+", linked to exactly 2 child nodes, "1" and "2".
In a slightly more complex example, (3 - (1 + 2)) can be represented by a peak node "-", which has 2 child nodes: a left child node of "3", and a right child node of "+". "+" also has 2 child nodes: "1" on the left, "2" on on the right.
In this way, every operator (plus, minus, times, divide, etc.) is a node with two children, and each value, or operand, is a leaf node (i.e. has no children).
Below are three expression trees.
Embed Notice
HTML Code
Corresponding Notice
- Embed this notice
Matt Cengia (mattcen@aus.social)'s status on Saturday, 07-Jun-2025 09:52:56 JST
Matt Cengia