Question: USING C++ The program will create and traverse expression trees in prefix, infix and postfix order. Print out traversal results and evaluate order of operations

USING C++

The program will create and traverse expression trees in prefix, infix and postfix order. Print out traversal results and evaluate order of operations from prefix notation.

The input will be read from a text file and each line will contain one infix expression to be processed.

For each input line, the program will:

  1. Check input line for errors
    1. print ALL errors detected
    2. if any errors detected go to next input line
  2. Convert infix statement to postfix notation and list expected output operations
  3. Build the corresponding expression tree and print the tree
  4. Print the traversal of the expression tree in prefix, infix and postfix order. Note: infix would be incorrect for evaluation as it will not have parenthesis (which is why infix changed to postfix in step 1)
  5. Evaluate value of expression using prefix notation
    1. Division will be integer division
    2. A = 1, B = 2, C = 3 ..
    3. What if you encounter a division by zero condition?
  6. Sample operation output:
  7. Input Line: A + B
  8. Valid Statement
  9. Postfix: AB+
  10. Operations:
  11. AB+
  12. Expression Tree:
  13. +
  14. A B
  15. Prefix: +AB
  16. Infix: A+B
  17. Postfix: AB+
  18. Evaluation:
  19. A + B = 3
  1. Final Result: 3

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!