Drawing ASTs for expressions: Correct Solution


For each of the Java expressions below:

Be sure that your tree accurately reflects how Java would evaluate the expression.

Part 1

Given the following variables:

double itio = 4.0;
double chetpas = 3.0;
int pa = 4;
double firis = 4.0;

...draw the AST and evaluation results for the following expression:

1 + itio - 4 / (6 - chetpas + 2 / pa) / 8 * firis

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean remtesh = true;
double bruicir = 2.0;
int casin = 6;
int miir = 8;
double micdong = 5.0;

...draw the AST and evaluation results for the following expression:

remtesh || 5 > 6 == (4 >= bruicir != 5 < 5 == casin < 5 && !(7 < 0)) || !(3 >= 6) || !(miir < micdong)

Solution

Things to double-check in your solution:


Part 3

Draw the AST and evaluation results for the following expression:

0 + (1 + 2 + 3 + "4" + 5) + 6 + "7" + 8 + 9

Solution

Things to double-check in your solution:


Related puzzles: