A binary expression tree is a specific kind of binary tree used to represent expressions, most commonly algebraic and boolean expressions, including those that contain both unary and binary operators. Like any binary tree, each node has zero, one or two children, a restricted structure that simplifies the processing of expression trees. In an algebraic expression tree the operators sit in the internal nodes and the numbers and variables in the leaf nodes, with binary operators taking two child nodes and unary operators one. Boolean expressions are represented in the same way, using true and false as constant values and operators such as AND, OR and NOT. A tree is constructed from an expression in postfix notation by reading its symbols one at a time: operands become one-node trees whose pointers are pushed onto a stack, and each operator pops the top two tree pointers and merges them under a new root, leaving one pointer to the finished tree.
Facts
Core PrincipleOperators are held in the internal nodes and operands such as constants or variable names in the leaves. 1 Sources
1. Expression trees, Colorado State University CS165
Dissecting an Expression Tree, first bullet
The internal nodes contain operators
Dissecting an Expression Tree, second bullet
The leaves are operands, such as constants or variable names.
View the SourceBinary expression tree (Wikipedia)
In Group: Tree Data Structures, LeadQuote, In Group: Tree Data Structures, Lead
A binary expression tree is a specific kind of a binary tree used to represent expressions.
View the Source Reader Challenges (0)
No disputes yet. Spotted an error or a better source? Open the first one.
Sign in to dispute this or suggest a correction.