0% found this document useful (0 votes)
5 views23 pages

02 Infix Prefix Postfix

The document explains the conversion of infix expressions to prefix expressions, detailing the precedence and associativity of operators. Examples illustrate how operators are rearranged based on their precedence and how parentheses influence the order of operations. The document highlights key rules for handling addition, multiplication, and exponentiation in this conversion process.

Uploaded by

sharada.sk10
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views23 pages

02 Infix Prefix Postfix

The document explains the conversion of infix expressions to prefix expressions, detailing the precedence and associativity of operators. Examples illustrate how operators are rearranged based on their precedence and how parentheses influence the order of operations. The document highlights key rules for handling addition, multiplication, and exponentiation in this conversion process.

Uploaded by

sharada.sk10
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

INFIX TO PREFIX

Infix expression Prefix expression Explanation


A+B +AB The operator +
moves before its two operands, A and B.
A+B*C +A*BC Multiplication (*) has a higher
precedence than addition (+). The * is
applied to B and C first, so *BC is formed. The + then applies to A
and the result of *BC to form +A*BC.

(A + B) * (C + D) *+AB+CD The innermost parentheses are


converted first. (A + B) becomes +AB
and (C + D) becomes +CD. The final operation, *, is then moved
to the front to combine the results.

A*B+C*D +*AB*CD Both * operations have higher


precedence than +. They are
converted first (*AB and *CD). The + is then placed at the
beginning.

A+B+C ++ABC Because + is left-associative, (A + B) is


evaluated first, becoming
+AB. The expression then becomes (+AB) + C, which is Converted
to ++ABC.

A^B^C ^A^BC The exponentiation operator ^ is right-


associative. This means A

You might also like