Draw a representation the following formula as a binary tree
1 + 2 * 3
Write code that is unit tested that will
- Produce the tree nodes necessary to represent the expression tree (30mins)
- Use anonymous functions for the operations
- Think polymorphism!
- Build a binary tree by parsing the string representing the formula in part A (1hr)
- Execute the operations and evaluate the tree by calling only the root tree node (1hr)
- Draw a representation the following formula as a binary tree
- Extend code developed in part A to allow the following expression to be evaluated
4 + 2 * 3 / 2 evaluates to 7
- Watch the following video on Inheritance, Polymorphism & Testing (1hr)
- Refactor your code so NO if, switch or new statements are used in objects that are used to define the binary tree. Objects for wiring (eg factories) may use if, switch or new statements
- Make sure your code works with the following Test case expressions
- 2+4+3 evaluates to 9
- 2+4*3 evaluates to 14
- 2/4*6 evaluates to 3
- 2+4*3+5 evaluates to 19
- 2+4*3-5 evaluates to 9
- 3+45+73*5-9 evaluates to 119
- 3+45+735-9/62+7 evaluates to 132
- Practices
- Binary tree structures
- Polymorphism
- SOLID
- Anonymous functions
- Unit tests