Infix expression to postfix form using the stack function, Data Structure & Algorithms

Q. Convert the following given Infix expression to Postfix form using the stack function: x + y * z + (p * q + r ) * s, Follow general precedence rule and suppose that the expression is legal.                                                                                         

Ans.

The given infix expression is as follows :-

x + y * z + (p * q + r) * s

Symb                Stack                    Postfix Expression x empty  x

+                       +                           x

y                       +                           xy

*                       +*                         xy

z                       +*                         xyz

+                       +                           xyz*+ (          +(         xyz*+

p                       +(                         xyz*+p

*                       +(*                       xyz*+p q       +(*       xyz*+p

+                       +(+                       xyz*+pq*

r                        +(+                       xyz*+pq*r

)                        +                           xyz*+pq*r+

*                       +*                         xyz*+pq*r+

s                        +*                         xyz*+pq*r+s

= xyz*+pq*r+s*+ The postfix expression obtained  is :- xyz*+pq*r+s*+

Posted Date: 7/12/2012 8:34:32 AM | Location : United States







Related Discussions:- Infix expression to postfix form using the stack function, Assignment Help, Ask Question on Infix expression to postfix form using the stack function, Get Answer, Expert's Help, Infix expression to postfix form using the stack function Discussions

Write discussion on Infix expression to postfix form using the stack function
Your posts are moderated
Related Questions
How to creat ATM project by using double linked list?

lower triangular matrix and upper triangular matrix

Q.1 What is an algorithm? What are the characteristics of a good algorithm? Q.2 How do you find the complexity of an algorithm? What is the relation between the time and space c

Explain how two dimensional arrays are represented in memory. Representation of two-dimensional arrays in memory:- Let grades be a 2-D array as grades [3][4]. The array will

If a node in a binary tree is not containing left or right child or it is a leaf node then that absence of child node can be represented by the null pointers. The space engaged by

Write an algorithm for getting solution to the Tower's of Hanoi problem. Explain the working of your algorithm (with 4 disks) with appropriate diagrams. Ans: void Hanoi(int

What do you mean by hash clash? Hashing is not perfect. Occasionally, a collision occurs when two different keys hash into the same hash value and are assigned to the same arra

Ask question #Minima binary search tree is used to locate the number 43 which of the following probe sequences are possible and which are not? explainum 100 words accepted#

Decision Tree A decision tree is a diagram that shows conditions and actions sequentially and therefore shows which condition is to be considered first, second and so on. It is

Define Prim's Algorithm Prim's  algorithm  is  a  greedy  algorithm  for  constructing  a  minimum  spanning  tree  of  a  weighted linked graph. It works by attaching to a bef