Menu

(Solved) : Using C Program Create Traverse Expression Trees Prefix Infix Postfix Order Print Traversa Q43968315 . . .

USING C++

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

The input will be read from a text file and each line willcontain 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 expectedoutput operations
  3. Build the corresponding expression tree and print the tree
  4. Print the traversal of the expression tree in prefix, infix andpostfix order. Note: infix would be incorrect for evaluation as itwill not have parenthesis (which is why infix changed to postfix instep 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

Expert Answer


Answer to USING C++ The program will create and traverse expression trees in prefix, infix and postfix order. Print out traversal …

OR