Convert the following algebraic expressions into computer expressions. (AB)+ (BC)
Answers
Answered by
11
Answer:
Postfix: AB *BC * +
Prefix: + * AB * BC
Explanation:
The expression you used is called infix and is human understandable.
Post and prefix expressions are easy for ci=computers to evaluate using data structures like stack.
Pre-Understanding:
While being evaluated the following is the order of operation:
- () : Boxes
- ^:exponents
- *,/ : multiplication, division
- +,- : Addition and subtraction.
How to do it?:
Consider your question here (A*B)+(B*C).
Since the boxes need to be solved first (pre-understanding section),
While converting in post fix the operands are written first followed by operation performed on them.
The steps are:
- For (A*B) : AB *
- For(B*C) : BC*
- Finally since (A*B)+(B*C) : AB* BC* +
Since we are adding (A*B) and (B*C) in the last one.
The reverse is true for Prefix expressions they are:
- *AB
- *BC
- +*AB*BC
Similar questions