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

Assignment Help:

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*+


Related Discussions:- Infix expression to postfix form using the stack function

What is Oscillating Sort?, For the Oscillating sort to be applied, it is ne...

For the Oscillating sort to be applied, it is necessary for the tapes to be readable in both directions and able to be quickly reversed. The oscillating sort is superior to the po

Binary search tree bst, Describe Binary Search Tree (BST)? Make a BST for t...

Describe Binary Search Tree (BST)? Make a BST for the given sequence of numbers. 45, 36, 76, 23, 89, 115, 98, 39, 41, 56, 69, 48 Traverse the obtained tree in Preorder, Inord

Multiple queue, algorithm for multiple queue with example program

algorithm for multiple queue with example program

Procedures, what is far and near procedures in system programming?

what is far and near procedures in system programming?

Write an algorithm outputs number of books using psuedocode, A shop sells b...

A shop sells books, maps and magazines. Every item is identified by a unique 4 - digit code. All books have a code starting with a 1, all maps have a code which starts with a 2 and

Determine the class invariants- ruby, Determine the class invariants- Ruby ...

Determine the class invariants- Ruby Ruby has many predefined exceptions classes (like ArgumentError) and new ones can be created easily by sub-classing StandardError, so it's

Advanced data structures, In this unit, the following four advanced data st...

In this unit, the following four advanced data structures have been practically emphasized. These may be considered as alternative to a height balanced tree, i.e., AVL tree.

Implement an algorithm to simulate car re-organizing, Design  and implement...

Design  and implement  an algorithm  to simulate car  re-organizing of the train at the railway switching junction. You can only use stacks as the data structure to represent the t

Algorithm, Ask question #MWhich of the following is not a characteristic of...

Ask question #MWhich of the following is not a characteristic of good algorithm? inimum 100 words accepted#

Implementing abstract data types, Implementing abstract data types A co...

Implementing abstract data types A course in data structures and algorithms is hence a course in implementing abstract data types. It may seem that we are paying a lot of atten

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd