Give the correct output for the following sequence of operations. Show all steps?
push(5)
push(8)
pop
push(2)
push(5)
pop
pop
pop
push(1)
pop
Answers
Answered by
6
Answer:
8 5 2 5 1 this is the ans of the given question
Answered by
0
output of the following sequence of operations is that the stack is empty
Explanation:
- here, stack data structure is used as the operation push and pop are used on stack data structure.
- push operation enters a data item in the stack and pop operation deletes a data item.
- stacks follow the rule LIFO (last in first out) which means that when a pop operation occurs it deletes the last entered data item through push operation.
- let the stack be denoted by 'S' hence following the given sequence of operations we get the output,
Similar questions