No, this is not correct. The answer should be "Infix to Postfix: a*b/c+d/e/f

  • MHB
  • Thread starter needOfHelpCMath
  • Start date
In summary, the expression "a*b/c+d/e/f" should be written as "ab*c/de/f/+" in postfix notation, with parentheses added to indicate the order of operations. It is important to remember the priority and left-to-right evaluation of operators.
  • #1
needOfHelpCMath
72
0
Code:
Here is my problem a*b/c+d/e/f:
*there is no code because professor ask me do hand write it out*

My answer: abc*/def//+is this correct?
 
Technology news on Phys.org
  • #2
needOfHelpCMath said:
Code:
Here is my problem a*b/c+d/e/f:
*there is no code because professor ask me do hand write it out*

My answer: abc*/def//+is this correct?

Hi needOfHelpCMath! (Smile)

It should be: [M]ab*c/de/f/+[/M]

That's because * and / have the same priority and are evaluated left to right.
So the expression is evaluated as [M]((a*b)/c)+((d/e)/f)[/M].
The postfix expression reflects that.
 
  • #3
I like Serena said:
Hi needOfHelpCMath! (Smile)

It should be: [M]ab*c/de/f/+[/M]

That's because * and / have the same priority and are evaluated left to right.
So the expression is evaluated as [M]((a*b)/c)+((d/e)/f)[/M].
The postfix expression reflects that.

thank you very much clarifies my mistakes!
 

FAQ: No, this is not correct. The answer should be "Infix to Postfix: a*b/c+d/e/f

What is the difference between infix and postfix notation?

Infix notation is when operators are placed in between the operands, while postfix notation places operators after the operands.

Why is postfix notation preferred in computer science?

Postfix notation is preferred because it eliminates the need for parentheses and has a fixed order of operations, making it easier for computers to evaluate expressions.

How do you convert an infix expression to postfix?

An algorithm called the shunting-yard algorithm can be used to convert an infix expression to postfix by using a stack to keep track of operators and parentheses.

What is the purpose of converting infix to postfix?

Converting infix to postfix allows for easier evaluation of expressions, as well as minimizing the use of parentheses and ensuring a fixed order of operations.

Can any infix expression be converted to postfix?

Yes, any infix expression can be converted to postfix using the shunting-yard algorithm, as long as the expression follows the rules of infix notation.

Similar threads

Replies
1
Views
981
Replies
1
Views
3K
Replies
3
Views
1K
Replies
14
Views
5K
Replies
1
Views
1K
Replies
7
Views
728
Replies
8
Views
2K
Back
Top