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

compare two functions n and 2n for various values of n. determine when second becomes larger than first

Create a Money data structure that is made up of amount and currency. (a) Write a constructor for this data structure (b) Create accessors for this data structure (c) Writ

Each of the comparison in the binary search decrease the number of possible candidates where the key value can be searched by a factor of 2 as the array is divided into two halves

Problem Your LC code is stored in a memory location as shown and the variable name is LC                  LC Memory address       Content(LC code)

Each data record contains a fixed place in a relative file. Each record ought to have associated with it in integer key value which will help identify this slot. Therefore, this ke

Explain an efficient way of storing a sparse matrix in memory.   A matrix in which number of zero entries are much higher than the number of non zero entries is called sparse mat

how to do a merge sorting

Define neotaxonomy. Discuss how electron microscopy can help in solving a zoological problem faced by taxonomist.

Implement a linear-expected-time algorithm for selecting the k th smallest element Algorithm description 1. If |S| = 1, then k = 1 and return the element in S as the an