Prefix and Postfix Expressions, Data Structure & Algorithms

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 )


The expression given is:


189_Prefix and postfix expression.png


The postfix expression obtained is:


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

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

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

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


The prefix expression obtained is:


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

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

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

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

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


Posted Date: 7/10/2012 3:47:37 AM | Location : United States

Related Discussions:- Prefix and Postfix Expressions, Assignment Help, Ask Question on Prefix and Postfix Expressions, Get Answer, Expert's Help, Prefix and Postfix Expressions Discussions

Write discussion on Prefix and Postfix Expressions
Your posts are moderated
Related Questions
how to design a cache simulator with 4-way set associative cache

Arrays :- To execute a stack we need a variable called top, that holds the index of the top element of stack and an array to hold the part of the stack.

What do you mean by hashing? Hashing gives the direct access of record from the file no matter where the record is in the file. This is possible with the help of a hashing func

Worst Case: For running time, Worst case running time is an upper bound with any input. This guarantees that, irrespective of the type of input, the algorithm will not take any lo

Question a) Describe how the endogenous model is an improvement to the neo-classical model in explaining the long-run effect of investment on economic growth of a country.

Q. What do you mean by the best case complexity of quick sort and outline why it is so. How would its worst case behaviour arise?

The location of a node in a binary search tree is defined as a string such as LLRRL, which represents the node that you find by starting at the root, and traversing Left, traverse

Type of Qualitative Method: Different  qualitative methods are suitable for different  types of study. Quite often we can  combine  qualitative and quantitative  methods. Many

Here is a diagram showing similarities between documents; this is an actual set of physics lab assignments from a large university. Each node (square) in the graph is a doc