plz i cant understand the stack operations,and iwant to know if the code is written in c or c++?
Converting and Evaluating Infix, Postfix and Prefix Expressions in C
#17
Posted 24 November 2011 - 05:30 PM
Thanks born2code, it's rare to find a clear explanation such as yours on topics such as this.
Appreciate your hard work.
I'll have to poke around at the code later, came here for the explanation of infix - prefix - postfix.
I'd add that after making an expression tree from a given expression, to produce the prefix notation, you write down the element the first time it is seen during traversal, for postfix, you write it down the last time it is seen during traversal. That is how it clicked for me.
Appreciate your hard work.
I'll have to poke around at the code later, came here for the explanation of infix - prefix - postfix.
I'd add that after making an expression tree from a given expression, to produce the prefix notation, you write down the element the first time it is seen during traversal, for postfix, you write it down the last time it is seen during traversal. That is how it clicked for me.
#18
Posted 22 September 2012 - 06:20 PM
Thnx!!
but just one question,in the one with the stack, this only works for displaying the postfix/prefix notation, how would you make the solution of the expression? for example you put 2+4, and this only works to show 2 4 +, but how would you make the actual operation and show the final result, which is 6?
I tried by myself editing the code, but I don't really know how to do it, please
but just one question,in the one with the stack, this only works for displaying the postfix/prefix notation, how would you make the solution of the expression? for example you put 2+4, and this only works to show 2 4 +, but how would you make the actual operation and show the final result, which is 6?
dude7788, on 22 September 2012 - 06:19 PM, said:
Thnx!!
but just one question,in the one with the stack, this only works for displaying the postfix/prefix notation, how would you make the solution of the expression? for example you put 2+4, and this only works to show 2 4 +, but how would you make the actual operation and show the final result, which is 6?
but just one question,in the one with the stack, this only works for displaying the postfix/prefix notation, how would you make the solution of the expression? for example you put 2+4, and this only works to show 2 4 +, but how would you make the actual operation and show the final result, which is 6?
I tried by myself editing the code, but I don't really know how to do it, please
#19
Posted 01 December 2012 - 03:59 AM
The code is absolutely fine. MY doubt is, why have you subtracted 48 from p's value in line 72 in the code of evaluating expression string.(this line :- push(&stk,*p - 48)
|
|






MultiQuote


|