Name:Yash .S.
Shekhawat
Batch:B4
Roll no.:95
Subject DS
Question:
Convert the following postfix expressions into prefix: ABC*+
Implement a python for the same problem
Ans. :
Postfix:
ABC*+
Step-by-Step:-
Step Operation Stack
Read A push A
Read B push A, B
Read C push A, B, C
Read * pop C & B → make *BC A, *BC
Read + pop *BC & A → +A*BC +A*BC
Prefix Expression:-
+A*BC
pg. 1
Name:Yash .S. Shekhawat
Batch:B4
Roll no.:95
Subject DS
Source code:-
Driver code:-
Output:-
pg. 2
Name:Yash .S. Shekhawat
Batch:B4
Roll no.:95
Subject DS
pg. 3
Name:Yash .S. Shekhawat
Batch:B4
Roll no.:95
Subject DS
pg. 4
Name:Yash .S. Shekhawat
Batch:B4
Roll no.:95
Subject DS
pg. 5
Name:Yash .S. Shekhawat
Batch:B4
Roll no.:95
Subject DS
pg. 6
Name:Yash .S. Shekhawat
Batch:B4
Roll no.:95
Subject DS
pg. 7
Name:Yash .S. Shekhawat
Batch:B4
Roll no.:95
Subject DS
pg. 8