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

Undirected graph and adjacency matrix, Q. Consider the specification writte...

Q. Consider the specification written below of a graph G V(G ) = {1,2,3,4} E(G ) = {(1,2), (1,3), (3,3), (3,4), (4,1)} (i)        Draw the undirected graph. (

Mapping constain, one to many one to one many to many many to one

one to many one to one many to many many to one

Process of in-order traversal, In-order Traversal  This process when ex...

In-order Traversal  This process when executed iteratively also needs a stack and a Boolean to prevent the implementation from traversing any portion of a tree twice. The gener

Effective way of storing two symmetric matrices, Explain an efficient and e...

Explain an efficient and effective way of storing two symmetric matrices of the same order in the memory. A n-square matrix array will be symmetric if a[j][k]=a[k][j] for all j

Which sorting algorithms not have running time of o (n2), Which sorting al...

Which sorting algorithms does not have a worst case running time of  O (n 2 ) ? Merge sort

Infix expression has balanced parenthesis or not, Q. By making use of stack...

Q. By making use of stacks, write an algorithm to determine whether the infix expression has balanced parenthesis or not.

Threaded Binary Tree, If a node in a binary tree is not containing left or ...

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

What is efficiency of algorithm, What is Efficiency of algorithm? Effic...

What is Efficiency of algorithm? Efficiency of an algorithm can be precisely explained and investigated with mathematical rigor.  There are two types of algorithm efficiency

Storing street addresses with doubly linked lists, Write a C++ program with...

Write a C++ program with header and source les to store street addresses using the Doubly Linked List ADT. Modify the Node class from Lab Assignment 3 so that it becomes a node in

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