converting infix to postfix

38 Views Asked by At
24 * (5 + 6) - 2 

I am trying to find the post fix for this I got this so far

24 5 * 6 2 + -

is this correct or wrong I am quite struggling with these

2

There are 2 best solutions below

0
On BEST ANSWER

$24 * (5 + 6) - 2$

first you need to remember the order of operations, basicaly everything on () is made first then multiplication, division and then sum and subctraction so in that case 5 + 6 is made first you start on 24 there a multiplication but since there start of ( you don't do the operation yet you get the sum 5 plus 6 wich lead to

24 5 6 +

now since ) ended and you have a subtraction wich is lower priority than * you do the multiplication

24 5 6 + *

now you just finish subtracting 2 leading to

24 5 6 + * 2 -

you answer is complet diferent from what you want

24 5 * 6 2 + -

leads to

$24*5 - (6 + 2)$

0
On

Wikipedia's Postfix notation gives an example of "4 * (5 + 8)" becoming "5 8 + 4 *". Using this concept, plus finishing with the $-2$ at the end, I believe one valid way to put $24 * (5 + 6) - 2$ into postfix notation would be

$$5 \; \, 6 \, + \, 24 \, * \, 2 \, \, - \tag{1}\label{eq1A}$$