1. Hi,

could someone help me with converting expression from prefix into postfix notation? The expression is long and it would be most helpful if someone could share the algorithm for converting between prefix, infix and postfix and propose a solution for the one below. I tried using expression tree but ended up nowhere.

The expression is: + / * A + B C + A B ^ - * A B C 2

Thanks!  2.

3. I'm going to assume this is homework, and so proceed carefully.

First, you understand infix notation and how it works, right? I'll assume you do In prefix notation, you have to keep a stack of operations. Basically + * A B C means push addition on the operation stack, then push multiplication on the operation stack. Next you have two numbers, so you can multiply them (A * B). Then you have another number (C), so you can add your numbers (A * B) + C (infix).

Postfix notation works with more of a numbers stack. The above example would be C B A * + (notice it's reversed). You start by pushing A, B and C onto a numbers stack. Then you use the mult operation to remove two numbers from the stack, multiply them, and push the result back on the stack. Then you use the addition operation to remove two numbers from the stack, and add them. So the final answer is again (A * B) + C (infix).  4. The infix notation is

A*(B+C)/(A+B)+A*B-C^2

The postfix notation is

ABC+*AB+/AB*C-2^+  Posting Permissions
 You may not post new threads You may not post replies You may not post attachments You may not edit your posts   BB code is On Smilies are On [IMG] code is On [VIDEO] code is On HTML code is Off Trackbacks are Off Pingbacks are Off Refbacks are On Terms of Use Agreement