# Thread: Changing (post/pre)fix expressions to infix

1. ## Changing (post/pre)fix expressions to infix

Hi,

I've been trying to figure this out for hours allready & couldn't.
I need to use manual transformation to change the following post/pre fix expressions to infix.
Any help is much appreciated! Thanks soo much

ABC +* D –
+ – *ABCD
–*A+BCD

Thanks again!

2. well postfix expression means that the operators come after the variables
and prefix means that hte operators come before the variables
so
ABC +* D - would be postfix
infix = ((A+B)*C)-D
you just grab a letter and then grab the first operator you see,
so A then + then B then * then C then - then D, and you put the brackets in.
pre fix is simliar but the opposite

3. well let me give a clue.. you can use stacks to solve this...
search the web for reverse polish and polish notation algorithms...

4. Originally Posted by paperbox005
well postfix expression means that the operators come after the variables
and prefix means that hte operators come before the variables
so
ABC +* D - would be postfix
infix = ((A+B)*C)-D
you just grab a letter and then grab the first operator you see,
so A then + then B then * then C then - then D, and you put the brackets in.
pre fix is simliar but the opposite
Thanks, but I don't think that's the answer as i've tried reversing the infix notation back to postfix to check the answer & it doesn't add up.
& aren't the brackets supposed to be by operator precendence : ((A + (B*C))–D ??

5. Originally Posted by vasanth
well let me give a clue.. you can use stacks to solve this...
search the web for reverse polish and polish notation algorithms...
I know , as im studying data structures right now with pseudocode in C.
But I need to be able to do this by manual transformation.

6. So can someone please still help me with this ?

7. I don't see any code, which means you obviously haven't bothered to read the Announcements.

Quzah.

8. Sorry I don't have code , it's just a question . Hope I didn't bother you too much

9. So what exactly was the question? It sounded like you wanted everyone to post code for you. I mean, it's not like you said "I don't understand how this algorithm works" or "I don't understand postfix/infix". You were already told what to search for, which you didn't do, because if you had, you wouldn't have followed up with "Can anyone help me?"

NO. We will not give you the code for it. Do it yourself. When you get stuck, post your attempt. Otherwise, do as you've been instructed, and go look it up.

Quzah.

10. You don't understand , I don't have too write code , just find the infix expressions to the post/prefix expressions I posted in my first post.

11. So why again did you post this on the C board?

Quzah.

12. Your feeling so superior aren't you ,because you know C?

13. I think what quzah is getting at is: why come to a programming board if you're not looking for help with a program? Shouldn't you be at a math site or something instead?

It's kind of like going to the dentist for a broken leg.

14. The book is Data structures, a pseudocode aproach with C . So no, im at the right site.

15. Originally Posted by Cmuppet
The book is Data structures, a pseudocode aproach with C . So no, im at the right site.
No you're not. Since you just said you don't want the code for it, then NO, you are not at the right site. I don't care what book you are reading from. If you do not want code, or help with code then stop posting on a programming forum.

You don't want code. You already said that. This isn't a "data structures" forum. It's a C Programming forum. You don't want C, you want to understand the concept itself. You don't want to use the tools, or to actually build something. You want to know how to read a blueprint. Now do you understand why you're in the wrong place?