Convert following infix expression to the prefix expression.
a - b + c * (d / e - (f + g))

Answer Posted / ashish

Algorithm for Infix to Prefix Conversion is
1. Reverse the given expression ...
2. Apply algorithm of infix to post-fix conversion...
3. Again reverse the expression after the post-fix conversion...


Infix Expression is => a - b + c * (d / e - (f + g))

step 1: => ( g + f ) - e / d ) * c + b- a

step 2: => apply post-fix ...

( ( g f + ) - e d / ) * c + b - a
( g f + e d / - ) * c + b - a
g f + e d / - c * + b - a
g f + e d / - c * b + - a
g f + e d / - c * b + a -

step 3: => final step reverse the expression ...

Prefix Expression = - a + b * c - / d e + f g

...
source :: http://scanftree.com/Data_Structure/infix-to-prefix

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between linked list and array?

485


Can we insert null in list?

490


Differentiate among cycle, path, and circuit?

517


What is sorting with example?

457


Differentiate linear from non linear data structure?

530






What are the major data structures used in the hierarchical data model?

539


What is difference between concurrenthashmap and hashtable?

416


What is a reverse linked list.

587


Explain what are the notations used in evaluation of arithmetic expressions using prefix and postfix forms?

518


Why hashmap is faster than hashset?

488


Which sorting is used in collections sort?

488


How long does it take to master data structures and algorithms?

653


Explain the applications of stack?

538


What are the advantages of stack?

448


Can we sort hashmap?

490