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 cuas = 8;
int gedi = 6;

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

9 / (cuas * gedi / 9 + 9 * 3 - 0 - 8 + 9 * 1 / 3)

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

double gion = 4.0;
int zent = 9;
boolean qadeck = false;
int vonbiss = 2;
int psoosmest = 7;
boolean scathran = true;
boolean ge = true;
double noicu = 4.0;
int cethro = 4;
int peotung = 7;
int qes = 2;

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

gion > zent || !!qadeck == vonbiss >= 6 && !(psoosmest < 8) && 5 <= 2 != scathran == ge != noicu <= 6 || !(cethro > peotung) == 2 < qes

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

Solution

Things to double-check in your solution:


Related puzzles: