Computer Science, asked by allysia, 1 month ago

Converting postfix to prefix and vice versa.
Explain with proper steps.

Answers

Answered by Anonymous
2

Postfix: An expression is called the postfix expression if the operator appears in the expression after the operands. Simply of the form (operand1 operand2 operator).

Example : AB+CD-* (Infix : (A+B) * (C-D) )

Prefix : An expression is called the prefix expression if the operator appears in the expression before the operands. Simply of the form (operator operand1 operand2).

Example : *+AB-CD (Infix : (A+B) * (C-D) )

Given a Postfix expression, convert it into a Prefix expression.

Conversion of Postfix expression directly to Prefix without going through the process of converting them first to Infix and then to Prefix is much better in terms of computation and better understanding the expression (Computers evaluate using Postfix expression).

Examples:

Input : Postfix : AB+CD-*

Output : Prefix : *+AB-CD

Explanation : Postfix to Infix : (A+B) * (C-D)

Infix to Prefix : *+AB-CD

Input : Postfix : ABC/-AK/L-*

Output : Prefix : *-A/BC-/AKL

Explanation : Postfix to Infix : ((A-(B/C))*((A/K)-L))

Infix to Prefix : *-A/BC-/AKL

Vice Versa Usage

You should use vice versa when you want to express that something you just said or wrote is true even in the opposite order. So, for example, if you're not particularly fond of your colleague, and you think the feeling is mutual, you can say: I don't like Bill, and vice versa.

I don’t like Bill, and vice versa.

In this sentence, you’re saying that you don’t like Bill, and Bill doesn’t like you. The subject becomes the object and vice versa.

We’ve used italics for vice versa in this post because we’re talking about the term itself, but in ordinary use there’s no need to italicize it or to enclose it in quotation marks. There’s also no need to hyphenate it—it’s always written as two separate words. You don’t need to capitalize it, either.

 \\  \\  \\  \\  \\  \\

Answered by Blink07
1

Postfix

An expression is called the postfix expression if the operator appears in the expression after the operands. Simply of the form (operand1 operand2 operator).

Example : AB+CD-* (Infix : (A+B) * (C-D) )

Prefix

An expression is called the prefix expression if the operator appears in the expression before the operands. Simply of the form (operator operand1 operand2).

Example : *+AB-CD (Infix : (A+B) * (C-D) )

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Given a Postfix expression, convert it into a Prefix expression.

Conversion of Postfix expression directly to Prefix without going through the process of converting them first to Infix and then to Prefix is much better in terms of computation and better understanding the expression (Computers evaluate using Postfix expression).

Examples

Input : Postfix : AB+CD-*

Output : Prefix : *+AB-CD

Explanation : Postfix to Infix : (A+B) * (C-D)

Infix to Prefix : *+AB-CD

Input : Postfix : ABC/-AK/L-*

Output : Prefix : *-A/BC-/AKL

Explanation : Postfix to Infix : ((A-(B/C))*((A/K)-L))

Infix to Prefix : *-A/BC-/AKL

Similar questions