Infix to Reverse Polish notation

In summary, Infix notation is a mathematical notation where operators are placed between operands, while Reverse Polish notation is a notation where operators are placed after operands. The purpose of converting Infix to Reverse Polish notation is to make it easier for a computer to evaluate the expression. This conversion is done using the shunting-yard algorithm, which follows the rules of Reverse Polish notation. Some advantages of using Reverse Polish notation include simplicity, efficiency, and the ability to eliminate ambiguity and reduce the number of parentheses in expressions. It also allows for easy conversion to and from other notations.
  • #1
itech4814
10
0
I have to convert..

X=A+((B+C)*D)-E

to reverse polish notation

I think it's...

BC+D*A+E-

Is this correct?
 
Technology news on Phys.org
  • #2
Looks right to me.
 
  • #3
Yes, that's one way to do it (verified on my HP calculator that uses RPN).

There are other ways, of course. For example, there's one that has the numbers in the sequence that they appear in the original infix expression. Can you figure that one out? It might be useful if you have to write a program that converts infix to RPN.
 

1. What is Infix notation?

Infix notation is a mathematical notation in which operators are placed between the operands. For example, in the expression 5 + 3, the operator "+" is placed in between the operands 5 and 3.

2. What is Reverse Polish notation?

Reverse Polish notation, also known as postfix notation, is a mathematical notation in which operators are placed after the operands. For example, in the expression 5 + 3, the operator "+" is placed after the operands 5 and 3, making it 5 3 +.

3. What is the purpose of converting Infix to Reverse Polish notation?

The purpose of converting Infix to Reverse Polish notation is to make the expression easier to evaluate for a computer. Reverse Polish notation eliminates the need for parentheses and follows a specific order of operations, making it simpler for a computer to process.

4. How is Infix to Reverse Polish notation conversion done?

Infix to Reverse Polish notation conversion is done using the shunting-yard algorithm. This algorithm uses a stack data structure to reorder the operands and operators in the expression, following the rules of Reverse Polish notation.

5. What are some advantages of using Reverse Polish notation?

Some advantages of using Reverse Polish notation include its simplicity and efficiency for computer processing, as well as its ability to eliminate ambiguity and reduce the number of parentheses in expressions. It also allows for easy conversion to and from other notations, making it a versatile choice for mathematical notation.

Similar threads

  • Programming and Computer Science
2
Replies
55
Views
4K
  • Programming and Computer Science
Replies
17
Views
1K
Replies
12
Views
2K
  • Biology and Chemistry Homework Help
Replies
8
Views
270
Replies
6
Views
176
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
25
Views
3K
Replies
4
Views
1K
Replies
2
Views
1K
Replies
8
Views
426
Back
Top