[go: up one dir, main page]

0% found this document useful (0 votes)
103 views12 pages

Class 12 - Evaluation of Postfix (Stack)

The document provides a detailed evaluation of postfix expressions using stack operations. It includes step-by-step actions taken for various expressions, demonstrating how to push and pop values while calculating results. Additionally, it covers logical operations using AND, OR, and NOT with corresponding outputs.

Uploaded by

vijay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
103 views12 pages

Class 12 - Evaluation of Postfix (Stack)

The document provides a detailed evaluation of postfix expressions using stack operations. It includes step-by-step actions taken for various expressions, demonstrating how to push and pop values while calculating results. Additionally, it covers logical operations using AND, OR, and NOT with corresponding outputs.

Uploaded by

vijay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Data Structures

Evaluation of
Postfix Expression
1. 50, 60, +,20, 10,-,
Step No. SymbolAction Taken Stack Output
Scanned
1. 50 Push 50

2. 60 Push 50,60
3. Pop 110 50+60
=110
4. 20 Push 110,20I
5. 10 Push 110,20,10
5. 10 Push 110,20,10
6. Pop 110,10 20-10
=10
7. Pop 11 110*10
2.30, 5,2, **,12,6,1,+,-
Step No. Symbol Action Taken Stack Outp
Scanned
1. 30 Push 30

2. 5 Push 30,5
3. 2 Push 30,5,2
4. ** (^) Pop 30,25 5**2
=25
5. 12 Push 30,25,12
6. 6 Push 30,25,12,6
6. 6 Push 30,25,12,6
7. Pop (12,6) 30,25,2 12/6
=2
8. Pop (25,2) 30,27 25+2

9. Pop(30,27) 3 30-27
=3
9. Pop(30,27) 3 30-27
=3

Ans. 3
3. False, True, NOT,OR, True, False, AND, OR
AND = True -> If all values are True.
OR = False >If allthe values are False.
NOT =True->False, False-> True
Step No. Symbol|ActAction Taken Stack Output
Scanned
AND= True -> If all values are True.
OR =False >If all the values are False.
NOT = True->False, False -> True
Step No. SymbolAction Taken Stack Output
Scanned
1. False Push False

2. True Push False,


True
3. NOT Pop(True) False, Not
False True
4.
7. AND Pop(True, False, False True
False) and
False
=False
8. OR Pop(False, False False
False) OR
False

Ans. False
2

4. True, False, NOT, OR, False, True, OR, AND

Step No. SymbolAction Taken Stack Output


Scanned
1. True Push True

2. False Push True, False


3. NOT Pop (False) Not
Faise
=True
4. OR Pop True

5. False Push True, False

6. True Push True,False, True


7. OR Pop(False, True) True,True F OR T

8. AND Pop (True, Tråe)True Tand


T
7. OR Pop(False,True)|True, True F OR T

8. AND Pop (True,True) True Tand


T

Ans. True

You might also like