The algorithm to convert infix to postfix is given on page 71 in handouts.View more random threads:
- What is generalization in c++ 2011
- What is difference among main() int main() void...
- i used Char data type to store a sentence but there is...
- The use of Function templates in C++ and C, java, php 2011
- Creating File Associations in c++ 2011
- What is cope and complexity in c++ 2011 ?
- what is object oriented programming and for what purpose we...
- what is the difference between 1. Double Right-Left...
- what does it mean " this->object=object"?
- what is the differnce b/w overriding and abstraction in c++...
In simple words,
if operand:
write in postfix string.
if operator:
if top of stack has more precedence than this operator
pop top of stack and append in postfix string. Continue until false. push new operator on stack
else if top of stack has less precedence than this operator
push it on stack
So, for the infix expression:
3 + 5 * 6 - 7 * ( 8 + 5)
Symbol
Postfix
Stack
3
3
+
3
+
5
3 5
+
Sponsored Links
*
3 5
*
+
6
3 5 6
*
+
-
3 5 6 *
-
+
7
3 5 6 * 7
-
+
*
3 5 6 * 7
*
-
+
(
3 5 6 * 7
(
*
-
+
8
3 5 6 * 7 8
(
*
-
+
+
3 5 6 * 7 8
+
(
*
-
+
5
3 5 6 * 7 8 5
+
(
*
-
+
)
3 5 6 * 7 8 5 +
*
-
+
3 5 6 * 7 8 5 + * - +
There are currently 1 users browsing this thread. (0 members and 1 guests)