Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible Trees using translation scheme for post fix notation of 7-2+3

I was asked to convert 7-2+3 into post fix notation while no operator precedence or left to right or right to left was mentioned in the question and then I had to make tree using translation scheme of the post fix notion ed result.

I found it ambiguous because 7-2+3 may give 2 possible results 8 and 2 so I wrote two post fix notations 72-3+ & 723+- and made two possible trees using translation scheme.

I want to confirm either I was Correct or Not.

like image 929
Ihtisham Ali Farooq Avatar asked Mar 24 '19 18:03

Ihtisham Ali Farooq


1 Answers

If you apply Shunting-yard algorithm to 7-2+3 the output is 72-3+

Note: + and - are left associative and have the same precedence unless otherwise indicated

like image 141
ivangalbans Avatar answered Oct 08 '22 01:10

ivangalbans