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:

int niaxslul = 3;
int mefon = 6;
double ipre = 2.0;

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

niaxslul - 9 / mefon + 4 + 5 / ipre - 4 * 2 / 3 - 0

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean riis = false;
double presm = 5.0;
boolean le = false;
boolean betob = true;
int qaglirst = 4;
boolean ooc = false;
int atrurm = 5;
double pi = 3.0;

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

(riis && !(6 >= presm) != le == 5 >= 6) || betob != qaglirst <= 3 && 6 != 5 == ooc || atrurm < pi

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: