programming in java
This project has been awarded to wangbeizou for $45 USD.Get free quotes for a project like this
Project Budget$10 - $30 USD
1. The purpose of the exercise is to practice building and traversing an expression
tree; so I want you to build a tree to hold the expression, and to evaluate the expression
by traversing the tree. you have to build the expression tree, then traverse it to evaluate
the expression. for each expression, you must produce
- a graphical representation of the tree,
- the numeric value of the expression.
2. Please use the following syntax for the arithmetic expressions that I want you to process:
<expression> ::= <term> | <term> + <expression> | <term> - <expression>
<term> ::= <factor> | <factor> * <term> | <factor> / <term>
<factor> ::= <constant> | ( <expression> )
<constant> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
You can make it slightly more complex by allowing greater integers than 9,
but you can let your constants range from 0 to 9 only.
3. Make sure you understand how this syntax defines operator precedence and associativity
operator precedence: 3*5+4 is interpreted as (3*5)+4 rather than 3*(5+4).
associativity rule: 3-5-4 is interpreted as 3-(5-4) rather than (3-5)-4.
Browse Related Skills
Other things people do on Freelancer
Looking to make some money?
- Set your budget and the timeframe
- Outline your proposal
- Get paid for your work
Hire Freelancers who also bid on this project
Looking for work?
Work on projects like this and make money from home!Sign Up Now
- The New York Times
- Wall Street Journal
- Times Online