Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. The purpose of the exercise is to practice building and traversing an express

ID: 3581442 • Letter: 1

Question

1. The purpose of the exercise is to practice building and traversing an expression tree; so I want you to build a tree to hold the expression, and to evaluate the expression by traversing the tree. you have to build the expression tree, then traverse it to evaluate the expression. for each expression, you must produce - a graphical representation of the tree, - the numeric value of the expression.

2. Please use the following syntax for the arithmetic expressions that I want you to process: ::= | + | - ::= | * | / ::= | ( ) ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 You can make it slightly more complex by allowing greater integers than 9, but you can let your constants range from 0 to 9 only.

3. Make sure you understand how this syntax defines operator precedence and associativity rule. operator precedence: 3*5+4 is interpreted as (3*5)+4 rather than 3*(5+4). associativity rule: 3-5-4 is interpreted as 3-(5-4) rather than (3-5)-4. NOTE: i want the code to be in java

Explanation / Answer

2.

1. The reason of the exercising is to exercise constructing and traversing an expression

tree; so I want you to construct a tree to hold the expression, and to evaluate the expression

by means of traversing the tree. you have to build the expression tree, then traverse it to evaluate

the expression. for every expression, you should produce

- a graphical representation of the tree,

- the numeric fee of the expression.

2. Please use the following syntax for the mathematics expressions that I need you to procedure ( <expression> )

<constant> ::= zero 1 3 4 five 8 9

you can make it barely extra complicated by means of allowing extra integers than nine,

but you could let your constants variety from zero to nine most effective.

3. ensure you recognize how this syntax defines operator priority and associativity rule.

operator precedence: 3*5+4 is interpreted as (three*five)+four in preference to 3*(5+four).

associativity rule: 3-5-4 is interpreted as three-(five-four) in place of (3-5)-4.