0% found this document useful (0 votes)
6 views

Exercise Questions

The document contains exercise questions focused on converting infix expressions to prefix and postfix forms, constructing binary expression trees, and performing various tree traversals. It includes tasks for evaluating prefix and postfix expressions, simplifying infix expressions, and challenge problems involving expression trees and algorithms for conversion. The exercises are designed to enhance understanding of expression evaluation and tree structures in computer science.

Uploaded by

Irfan Ul Haq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Exercise Questions

The document contains exercise questions focused on converting infix expressions to prefix and postfix forms, constructing binary expression trees, and performing various tree traversals. It includes tasks for evaluating prefix and postfix expressions, simplifying infix expressions, and challenge problems involving expression trees and algorithms for conversion. The exercises are designed to enhance understanding of expression evaluation and tree structures in computer science.

Uploaded by

Irfan Ul Haq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Exercise Questions

Practice Prefix, Infix, Postfix Conversion and Binary Tree Construction

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

○ Write an algorithm to automatically parse and convert the following infix


expressions into their equivalent prefix and postfix forms:

a) W×X−Y+Z/P−Q×R+S

○ b) L+M×N−O/P+Q×R−S

You might also like