Exercise Questions
Exercise Questions
1. Convert the following infix expression to prefix and postfix forms. Then construct a
binary expression tree and perform preorder, inorder, and postorder traversals.
a) A+B×C−D/E+F×G−H
b) P×Q+R−S/T+U×V−W
2. c) X+Y×Z−M/N+O×P−Q
3. Evaluate the following prefix expressions and convert them to infix and postfix forms:
a) −+A×BC/DE+F×GH
b) +∗PQ/RS−T×UV
4. Evaluate the following postfix expressions and convert them to infix and prefix forms:
a) ABC×+DE/−FG×+H-
5. b) PQ∗RS/+TU∗V−−
6. For the following expressions, construct the corresponding binary expression tree and
write the preorder, inorder, and postorder traversals:
a) A×B+C−D/E+F×G
7. b) X+Y×Z−P/Q+R×S−T
8. Simplify the following infix expressions by applying operator precedence rules (no
brackets are allowed). Then, convert to prefix and postfix forms:
a) A+B×C−D/E×F+G−H
9. b) P×Q+R−S/T+U×V
Challenge Problems
6. Given the infix expression below, construct the expression tree, and evaluate the final
result if:
○ A=5,B=3,C=8,D=4,E=2,F=6,G=7,H=1
○ Expression: A+B×C−D/E+F×G−H
a) W×X−Y+Z/P−Q×R+S
○ b) L+M×N−O/P+Q×R−S