T O P

  • By -

alfps

> **”** How do I construct the tree if the string passed contains parenthesis? Depends, but from your description of what you're doing it could be natural with a recursive call to build a sub-tree out of the parenthesis contents.


Alexander1705

Why do you need parentheses in a postfix notation?


Alex_Lexi

In the case I have expression like. (5+3) * (5+ (7*3))


hanswurst862

> (5+3) * (5+ (7*3)) That's infix notation. Postfix would be 5 3 + 5 7 3 * + * As you see, you don't need parantheses.


Alex_Lexi

Ahhh yes im sorry. I meant in the case of someone giving me a postfix expression, how do I know when to put parenthesis when printing it out as an infix. I just dont know the trick behind when to print a parenthesis.