Please ask your queries or doubts in the comments section.
Please allow 2-3 hours to reply.
Thank you and Best of luck!
Solution to Jitesh Khuttan's question on Converting Infix to Postfix notation (asked via WhatsApp)
There is an algorithm to convert an infix expression into a postfix expression. It uses a stack; but in this case, the stack is used to hold operators rather than numbers. The purpose of the stack is to reverse the order of the operators in the expression. It also serves as a storage structure, since no operator can be printed until both of its operands have appeared.
In this algorithm, all operands are printed (or sent to output) when they are read. There are more complicated rules to handle operators and parentheses.
1. A * B + C becomes A B * C +
The order in which the operators appear is not reversed. When the '+' is read, it has lower precedence than the '*', so the '*' must be printed first.
We will show this in a table with three columns. The first will show the symbol currently being read. The second will show what is on the stack and the third will show the current contents of the postfix string. The stack will be written from left to right with the 'bottom' of the stack to the left.
|Current Symbol||Operator Stack||Postfix String|
|4||+||+||A B * (pop and print the '*' before pushing the '+')|
|5||C||+||A B * C|
|6||A B * C +|