Search code examples
stackpostfix-notationinfix-notation

Convert Infix expression to Postfix


Convert the following infix expression to postfix:

True Or False And Not False Or False [Comptt 2005]

According to me, The answer should be:

True false false not and or false or 

Considering the precedence order Not>and>or ((true or (false and (not false))) or false)

But according to the book, the answer is:

True False Or False Not and False or

They did it by: (((True or False)And (Not False))Or False)


Solution

  • Your answer is right.One clear mistake in the book answer is that precendence of conditional or is not greater than conditional and therefore the parenthesized expression would be:

    ((True Or (False and (NOTFalse)))Or False).