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
First - Fit Method: -    The free list is traversed sequentially to search the 1st free block whose size is larger than or equal to the amount requested. Once the block is found it


The above 3 cases are also considered conversely while the parent of Z is to the right of its own parent. All the different kind of cases can be illustrated through an instance. Le

the voltage wave forms are applied at the inputs of an EX-OR gate. determine the output wave form

The Linked list is a chain of structures wherein each structure contains data in addition to pointer, which stores the address (link) of the next logical structure in the list.

Explain the representations of graph. The different ways of representing a graph is: Adjacency list representation : This representation of graph having of an array Adj of

What is Algorithm A finite sequence of steps for accomplishing some computational task. An algorithm should Have steps which are simple and definite enough to be done

It is a naturally occurring sorting method exemplified through a card player arranging the cards dealt to him. He picks up the cards like they are dealt & added them into the neede

Sorting is significant application activity. Several sorting algorithms are obtainable. But, each is efficient for a specific situation or a specific kind of data. The choice of a

Illustrate an example of algorithm Consider that an algorithm is a sequence of steps, not a program. You might use the same algorithm in different programs, or express same alg