Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
9.8k views
in Computer by (61.3k points)

Evaluate the following postfix expression using a stack and show the contents of the stack after execution of each operation 5, 11, -, 6, 8, +, 12, *, /

1 Answer

+1 vote
by (64.2k points)
selected by
 
Best answer
SNo Symbo Action taken Stack Intermediate output
1 5 operand, push 5
2 11 operand, push 5,11
3 - operator, pop twice 5-11=-6
Evaluate and push back 6
4 6 operand, push 6,-6
5 8 operand, push 6,-6,8
6 + operator, pop twice 6 -6+8=-14
Evaluate and push back 6,14
7 12 operand, push 6,14,12
8 * operator, pop twice 6 12*14=168
Evaluate and push back 6,168
9 / operator, pop twice 168/6
10 pop all -1/28

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...