“Create a binary expression tree for (a × b) + (c − (d ÷ (e + f))), with + as the root, × on the left and − on the right.”
פענחו את ההחלטות שמאחוריו.
Put the outermost addition at the root.
Give every operator a left and right child.
Group multiplication and subtraction before addition.
Use this tree to explain parsing and expression evaluation.
שאלות נפוצות
What are the leaves in an expression tree?
Leaves are operands such as numbers, variables or constants.
Why use a binary tree for an expression?
Binary operators naturally have a left operand and a right operand.
How is the root chosen?
It is the outermost operation, performed after its two subexpressions.