Answer to Question #228178 in Algorithms for umme habiba sumi

Question #228178

Consider the following infix expression

Q: ((A+C)*D)ꜛ(B+F/E)+G use POLISH Algorithm to translate Q into its equivalent postfix expression P.

Let A, B, C, D, E, F, G, H be eight data items with the following assigned weights:


Data item: A B C D E F G H

Weight: 20 7 11 17 5 10 24 6

Construct Binary tree using Huffman Algorithm also find the path length of the tree.


1
Expert's answer
2021-08-22T00:28:05-0400

1)

S=((A+C)*D)^(B+F/E)+G infis string

RES= "" = postfix string

STACK=""- stack of operations;

2)

S=(A+C)*D)^(B+F/E)+G

RES=""

STACK=(

3)

S=A+C)*D)^(B+F/E)+G

RES=""

STACK=((

4)

S=+C)*D)^(B+F/E)+G

RES=A

STACK=((

5)

S=C)*D)^(B+F/E)+G

RES=A

STACK=((+

6)

S=)*D)^(B+F/E)+G

RES=AC

STACK=((+

7)

S=*D)^(B+F/E)+G

RES=AC+

STACK=(

8)

S=D)^(B+F/E)+G

RES=AC+

STACK=(*

9)

S=)^(B+F/E)+G

RES=AC+D

STACK=(*

10)

S=^(B+F/E)+G

RES=AC+D*

STACK=

11)

S=(B+F/E)+G

RES=AC+D*

STACK=^

12)

S=B+F/E)+G

RES=AC+D*

STACK=^(

13)

S=+F/E)+G

RES=AC+D*B

STACK=^(

14)

S=F/E)+G

RES=AC+D*B

STACK=^(+

15)

S=/E)+G

RES=AC+D*BF

STACK=^(+

16)

S=E)+G

RES=AC+D*BF

STACK=^(+/

17)

S=)+G

RES=AC+D*BFE

STACK=^(+/

18)

S=+G

RES=AC+D*BFE/+

STACK=^

19) ^ has bigger priority than +

S=G

RES=AC+D*BFE/+^

STACK=+

20)

S=

RES=AC+D*BFE/+^G

STACK=+

21)

S=

STACK=

RES=AC+D*BFE/+^G+

AC+D*BFE/+^G+ equivalent postfix expression P

Task 2:

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS