Question: You are writing a system to evaluate arithmetic expressions. The operations are add, subtract, multiply, and divide. Examples are: 5+3(15.73)1.6(3+8)(4+(189)/2.1) (Note: you may assume that

 You are writing a system to evaluate arithmetic expressions. The operations

You are writing a system to evaluate arithmetic expressions. The operations are add, subtract, multiply, and divide. Examples are: 5+3(15.73)1.6(3+8)(4+(189)/2.1) (Note: you may assume that all operations are binary.) One way of implementing this is using a binary tree: consider that an expression consists of a left-hand sub-expression, a right-hand sub-expression, and an operation. For example, the (3+8)(4+(189)/2.1) expression may be expressed as: Left sub-expression: 3+8 Right sub-expression: 4+(189)/2.1 Operation: multiplication We can further break the left into sub-expressions for 3 and 8 , with addition as the operation. Multi Part Question: A) What pattern works well to implement these operations? Justify your answer. B) You will notice that expressions can be rather complex, but a pattern will help us tame the complexity. What pattern would would work best to handle the expressions (Hint: It is not the Command or Observer). Justify your

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!