Stack data structure can be used to convert an Infix expression to post-fix expression the algorithm uses a stack which used to store the operators in the expression and two strings one is the input string contains the given infix expression and the other string hold the output post-fix string. a function is used to check the precedence of the operators which is defined as follows
- preceed(op1,op2) = true if op1>=op2
- preceed(op1,op2) = false if op1<op2
- preceed('(',op2) = false for any operator
- preceed(op1,'(') = false for any operator other than ')'
- preceed(op1,')') = true for any operator other than '('
- preceed (')',op2) = is undefined
No comments:
Post a Comment