Read the paragraph and answer the question. A stack is a linear data structure…
2023
Read the paragraph and answer the question.
A stack is a linear data structure in which insertion and deletion of elements are done at only one end, known as the top of the stack. A stack follows the last-in-first-out (LIFO) principle.
In the given stack, the elements from top to bottom are: L, M, N, O, P, Q.
After popping/removing three items from the stack, which item will be at the top?
- A.
O
- B.
L
- C.
N
- D.
P
Attempted by 704 students.
Show answer & explanation
Correct answer: A
Correct Answer: O
The stack elements from top to bottom are: L, M, N, O, P, Q.
A stack follows LIFO, so deletion/pop happens from the top.
First pop: L is removed.
Second pop: M is removed.
Third pop: N is removed.
After these three removals, the next element at the top is O.
Therefore, the correct answer is O.