Send Close Add comments: (status displays here)
Got it!  This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
Tree evaluation


1. Tree evaluation
Expression tree for (X & Y) | ((! X) & (! Y))A tree traversal can be used to return the value of a logical expression tree, given that the values of the logical variables are known.

A dictionary is passed to the tree evaluation routine that maps variable names to values.

Diagnostic print statements are used to show a trace of the evaluation.
( X & Y ) | ( ( ! X ) & ( ! Y ) )

Here is the JavaScript code.

Here is the output of the JavaScript code.


2. Next steps
The next step is to separate the evaluate process, that takes a tree and an environment to evaluate a result, into two parts. The stack-based code is the basis for instruction set code.

3. End of page