Data Structure & Algorithm Interview Questions And Answers - Part X.
Answer: Polish string refers to the notation in which the operator symbol is placed either before its operands (prefix notation) or after it operands (postfix notation). The usual form, in which the operator is placed in between the operands is called infix notation.
Answer: An expression where operators are placed in between the operands is called a infix expression.
An expression where operators are placed after the operands is called a postfix expression.
An expression where operators are placed before the operands is called a prefix expression.
The operators with the same priority are evaluated from left to right.
Answer: An infix expression is evaluated keeping in mind the precedence of operators. An infix expression is difficult for the machine to know and keep track of precedence of operators. A postfix expression itself takes care of the precedence of operators as the placement of operators. Thus, for the machine, it is easier to carry out a postfix expression than an infix expression.
Answer: A prefix expression is converted to infix expression by scanning from left to right until we find the first operator that is immediately followed by a pair of operands. This binary expression is converted to infix by placing the operator in between two operands. The resultant expression continues until all the operators are placed between operands.