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

Structures for complete undirected graphs, Q. Draw  the structures of compl...

Q. Draw  the structures of complete  undirected  graphs  on  one,  two,  three,  four  and  five vertices also prove that the number of edges in an n vertex complete graph is n(n-1

Program segment for quick sort, Illustrates the program segment for Quick s...

Illustrates the program segment for Quick sort. It uses recursion. Program 1: Quick Sort Quicksort(A,m,n) int A[ ],m,n { int i, j, k; if m { i=m; j=n+1; k

Define queue fifo ?, A queue is a particular type of collection or abstract...

A queue is a particular type of collection or abstract data type in which the entities in the collection are went in order and the principal functions on the collection are the add

Relation of time and space complexities of an algorithm, What is complexity...

What is complexity of an algorithm? What is the basic relation between the time and space complexities of an algorithm? Justify your answer by giving an example.

Queue, what''s queue ?

what''s queue ?

Sorted list using binary search technique, Write an algorithm for searching...

Write an algorithm for searching a key from a sorted list using binary search technique 1.   if (low > high) 2.     return (-1) 3.    mid = (low +high)/2; 4    .if ( X

What are circular queues, What are circular queues?  Circular queue: St...

What are circular queues?  Circular queue: Static queues have a very large drawback that once the queue is FULL, even though we erase few elements from the "front" and relieve

Indexed sequential files, Indexed Sequential Files An index is inserted...

Indexed Sequential Files An index is inserted to the sequential file to provide random access. An overflow area required to be maintained to permit insertion in sequence. I

Determine the components of illumination, Determine the Components of Illum...

Determine the Components of Illumination The light reaching the eye when looking at a surface has clearly come from a source (or sources) of illumination and bounced off the su

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