Question: task 3 in python Task 1: Implement the Expression Tree class from Chapter 8 (Section 8.5) of the book. Task 2: Note that the build

task 3 in python
Task 1: Implement the Expression Tree class from Chapter 8 (Section 8.5) of the book. Task 2: Note that the build expression tree function of the Expression Tree class is written in such a way that a leaf token can be any string; for example, it parses the expression (a*(b+c)). However, within the evaluate method, an error would occur when attempting to convert a leaf token to a number. Modify the evaluate method to accept an optional Python dictionary that can be used to map such string variables to numeric values, with a syntax such as T.evaluate({ a :3, :1, c:5}). In this way, the same algebraic expression can be evaluated using different values. Task 3: Implement a postfix method of the Expression Tree class of Section 8.5 that produces the postfix notation for the given expression. Hint: Use postorder traversal
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
