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 representation and traversal
c
go
java
js
lua
py
vbs
rkt
scm
pro
1. Tree representation and traversal
2. Tree representation
3. Logical expression
This page looks at how logical expressions can be represented and traversed using JavaScript code.
The (fully parenthesized) logical expression is as follows.
( X & Y ) | ( ( ! X ) & ( ! Y ) )
4. Code conventions
The following code examples use the following.
A dictionary to look up the symbol name for a given operator name.
A prefix tree representation of the above logical expression.
The name "op1 " is for a unary operator. The type and one argument follows.
The name "op2 " is for a binary operator. The type and two argument follow.
Note: All tree lists are the same, but could not be easily separated for this page.
5. Code examples
The following code examples are provided.
Prefix: line by line
Infix: line by line
Postfix : line by line
Prefix: text string
Infix: text string
Postfix: text string
Study each one to understand how it works.
6. JavaScript code
Here is the JavaScript code.
7. JavaScript output
Here is the output of the JavaScript code.
8. JavaScript code
Here is the JavaScript code.
9. JavaScript output
Here is the output of the JavaScript code.
10. JavaScript code
Here is the JavaScript code.
11. JavaScript output
Here is the output of the JavaScript code.
12. JavaScript code
Here is the JavaScript code.
13. JavaScript output
Here is the output of the JavaScript code.
14. JavaScript code
Here is the JavaScript code.
15. JavaScript output
Here is the output of the JavaScript code.
16. JavaScript code
Here is the JavaScript code.
17. JavaScript output
Here is the output of the JavaScript code.
18. End of page