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 ondche = 3.0;
double edun = 5.0;
double in = 3.0;
int nileist = 4;
int stouson = 6;
int o = 5;

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

7 / 4 - ondche * edun - in % (nileist * 0 - stouson / o - 2)

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

int se = 3;
int urdsin = 3;
int dipress = 5;
double miee = 1.0;
boolean stesen = true;
int er = 4;
double ko = 5.0;
boolean hi = false;
int chosa = 5;

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

!(7 <= se) || !(7 >= urdsin) || 8 <= dipress != miee <= 7 != stesen && er > 2 == 7 > ko && hi == 4 < chosa

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 + "10"

Solution

Things to double-check in your solution:


Related puzzles: