top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Which data structure is used in evaluation of Arithmetic Expressions written in Prefix or Postfix forms?

+2 votes
532 views
Which data structure is used in evaluation of Arithmetic Expressions written in Prefix or Postfix forms?
posted Jul 1, 2016 by Mohammed Hussain

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
What is the meaning of notation here.
agree , question isn't clear Md. Hussain.Please explain more for your ans

1 Answer

0 votes

usually stack is used.

example:
algorithm for postfix expression:
1) take eg. 123*+ . scan the expression, whenever operand comes push to stack.
2) when operator comes pop 2 operands from stack and compute result and push to stack again
3)stack-> push 1,2,3 => stack will be 3,2,1 (3 at the bottom)
4)pop 1,2. now do 1*2=2. push 2 to stack. now stack is 3,2
5) pop 2,3. now do 2+3=5.
6) now scanning the expression 123*+ is completed thus 5 is the result

answer Aug 25, 2016 by Sneha Maganahalli
...