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 woi = 2;
double tasteng = 5.0;

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

woi + 7 + 3 * 9 % tasteng * 6 / 4 % 7 - 0 - 4

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

int oc = 5;
int iast = 5;
int udhan = 9;
double mente = 4.0;
double fleshthe = 1.0;
double pi = 3.0;
double veid = 5.0;
int sphuleor = 3;
int ceis = 5;

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

0 < oc || 8 == 4 || iast != udhan && mente < 6 || 1 != fleshthe == pi > veid && 1 <= 8 == 0 >= sphuleor == (3 == ceis)

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: