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

Answers were Sorted based on User's Feedback



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

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

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

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

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

Answer / saravanakumar

+-ab*c-/de+fg

Is This Answer Correct ?    12 Yes 10 No

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

Answer / bhupendra pattnayak

*-a+bc-/de+fg

Is This Answer Correct ?    54 Yes 54 No

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

Answer / mona

+-ab*c-/dc+gf

Is This Answer Correct ?    4 Yes 4 No

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

Answer / waqar

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

Is This Answer Correct ?    1 Yes 1 No

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

Answer / sheeraz

*-a+bc-/de+fg

Is This Answer Correct ?    0 Yes 0 No

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

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

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

Answer / ramen pradhan

-a+b*c-/de+fg

Is This Answer Correct ?    1 Yes 1 No

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

Answer / harsh parikh

-a+b*c-/de+fg

Is This Answer Correct ?    4 Yes 5 No

Post New Answer

More Data Structures Interview Questions

Differentiate file structure from storage structure?

0 Answers  


What is queue in data structure?

0 Answers  


What is time complexity of bubble sort?

0 Answers  


Why do we need linked lists?

0 Answers  


how to search an element in sorted linked list with time complexity is O(log n).

3 Answers   Wipro,






What are the properties of an algorithm?

0 Answers  


Explain quick sort and merge sort algorithms and derive the time-constraint relation for these.

0 Answers   MNB,


What is map data structure?

0 Answers  


What is the minimum number of nodes that a binary tree can have?

0 Answers  


What is time complexity of arrays sort?

0 Answers  


an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like. [ I ended up giving about 4 or 5 different solutions for this, each supposedly better than the others ].

0 Answers  


Tell me the difference between structure and array?

0 Answers   NIIT,


Categories