Convert following infix expression to the prefix expression.
a - b + c * (d / e - (f + g))
Answers were Sorted based on User's Feedback
Answer / naresh
first u need to reverse the given string like this..
))g+f(-e/d(*c+b-a..
after doing this, we need to consider a stack n insert symbolls into the stack whenever u encountered it in the string..
sequence of flow is:
g
f
+
e
d
/
-
c
*
b
+
a
-......
the string obtained is gf+ed/-c*b+a-..
u need to reverse the string for answer i.e
ans is -a+b*c-/de+fg..
| Is This Answer Correct ? | 28 Yes | 23 No |
Answer / 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 |
Answer / rodel
given-> a - b + c * (d / e - (f + g))
note: remember, before we do the infix expression to postfix expression.
We analyze the given data by using the hierarchy of operation (PEMDAS)
In that way, we can do the operation, tracing the hierarchy nos...
sample:
a - b + c * (d / e - (f + g))
5 6 4 2 3 1
pass1: a - b + c * (d / e - (f g +)) infix -> postfix
pass2: a - b + c * (d e / - f g +) infix -> postfix
pass3: a - b + c * (d e / - f g +) infix -> postfix
pass4: a - b + c * (d e / f g + - ) infix -> postfix
pass5: a b - + c d e / f g + - * infix -> postfix
pass6: a b - c + d e / f g + - * infix -> postfix -> Final Answer
| Is This Answer Correct ? | 0 Yes | 0 No |
What is red black tree in data structure?
How is hashmap o 1?
What is subtree?
How can you insert a node at the end of linked list?
Why is data structure?
what is the difference between Linear Array and Linked List?
Is quicksort recursive?
What is bitonic search?
What is binary tree used for?
Does list allow null values?
What is list data structure?
How do you declare A pointer to array of three chars