show the stack after each operation of the following sequence that starts with the empty stack: push(a), push(b), pop, push(c), push(d), pop
(equations and math to be done in Latex math symbols)
Solution
Push-inserting elements into the stack
Pop-deleting elements from the stack
Stack follows LIFO policy
LIFO-Last In First Out
Last Inserted element will be out first
push(a)
“a” is pushed into stack
a |
push(b)
“b” is pushed into stack
b |
a |
pop
top of the item will be popped out so “b” will be popped out
a |
push(c)
“c” will be pushed into stack
c |
a |
push(d)
“d” will be pushed into stack
d |
c |
a |
pop
top of the element “d” will be popped out
c |
a |
final stack
c |
a |
--
I have given basic solution
if you have any doubt and if you need anything else, please mention it
love to help
all the best
Get Answers For Free
Most questions answered within 1 hours.