Prefix and Postfix Expressions, Data Structure & Algorithms

Assignment Help:

Q. Draw the expression tree of the infix expression written below and then convert it intoPrefix and Postfix expressions.

((a + b) + c * (d + e) + f )* (g + h )

Ans:

The expression given is:

 

189_Prefix and postfix expression.png

 

The postfix expression obtained is:

((a+b)+c*(d+e)+f)*(g+h)

= ((ab+)+c*(de+)+f)*(gh+)

= ((ab+)+(cde+*)+f)*(gh+)

= ((ab+cde+*+)+f)*(gh+)

= (ab+cde+*+f+)*(gh+)

=(ab+cde+*+f+gh+*)

The prefix expression obtained is:

((a+b)+c*(d+e)+f)*(g+h)

= ((+ab)+c*(+de)+f)*(+gh)

= ((+ab)+(*c+de)+f)*(+gh)

= ((++ab*c+de)+f)*(+gh)

= (+++ab*c+def)*(+gh)

= (*+++ab*c+def+gh)

 


Related Discussions:- Prefix and Postfix Expressions

Stack making use of the linked list, Q. Implement a stack making use of the...

Q. Implement a stack making use of the linked list. Show the PUSH and POP operations both. A n s . Stack implemantation using linked list # include # include

Preorder - postorder and inorder, 1) preorder, postorder and inorder 2) ...

1) preorder, postorder and inorder 2) The main feature of a Binary Search Tree is that all of the elements whose values is less than the root reside into the nodes of left subtr

Abstract data type-list, It is a useful tool for indicating the logical pro...

It is a useful tool for indicating the logical properties of data type. It is a collection of values & a set of operations on those values. Methodically, "a TYPE is a set, & elemen

Pipeling, Asktypes of pipelining question #Minimum 100 words accepted#

Asktypes of pipelining question #Minimum 100 words accepted#

Illustrate the wire frame representation, RENDERING, SHADING AND COLOURING ...

RENDERING, SHADING AND COLOURING By introducing hidden line removal we have already taken one step away from wire-frame drawings towards being able to realistically model and d

What is string, What is String Carrier set of the String ADT is the s...

What is String Carrier set of the String ADT is the set of all finite sequences of characters from some alphabet, including empty sequence (the empty string). Operations on s

Write down any four applications of queues, Write down any four application...

Write down any four applications of queues.            Application of Queue (i)  Queue is used in time sharing system in which programs with the similar priority form a queu

Graph search using iterative deepening, Prove that uniform cost search and ...

Prove that uniform cost search and breadth- first search with constant steps are optimal when used with the Graph-Search algorithm (see Figure). Show a state space with varying ste

Matrices multiplication, Write an algorithm for multiplication of two spars...

Write an algorithm for multiplication of two sparse matrices using Linked Lists.

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