Question: Consider the arithmetic expressions below. For each: (a) draw its correct AST, (b) show the intermediate value of each inner-node, evaluating bottom-up, (c) write the

Consider the arithmetic expressions below. For each: (a) draw its correct AST, (b) show the intermediate value of each inner-node, evaluating bottom-up, (c) write the same expression in Polish notation, and (d) evaluate in Polish notation using stack-based evaluation as discussed in class (show each intermediate redex).

i. 1 + 2 + 3

ii. 1 + (3 4 2 2)

iii. 2 (5 4) 3

iv. 1 + 2 3 + 4 5 + 6

v. 3 (7 8) 4 (5 2 1) 1

vi. 2 3 + 4 6 1 (1 1 1) 6 (3 + 6)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!