I am preparing for an exam where i couldn\'t understand the convertion of infix notation to polish notation for the below expression:
(a–b)/c*(d + e – f / g)
In Prefix expression operators comes first then operands : +ab[ oprator ab ]
Infix : (a–b)/c*(d + e – f / g)
Step 1: (a - b) = (- ab) [ '(' has highest priority ]
step 2: (d + e - f / g) = (d + e - / fg) [ '/' has highest priority ]
= (+ de - / fg )
['+','-' has same priority but left to right associativity]
= (- + de / fg)
Step 3: (-ab )/ c * (- + de / fg) = / - abc * (- + de / fg)
= * / - abc - + de / fg
Prefix : * / - abc - + de / fg