A stack is a liner data structure in which insertion and deletion of elements are done at only one end, which is known as the top of the stack. Stack is called a last-in, first-out (LIFO) structure because the last element which is added to the stack is the first element that is deleted from the stack.
| Top | L |
| M | |
| N | |
| O | |
| P | |
| Bottom | Q |
Read the above paragraph and answer the following.
Which of the following items will be at the top in the stack after removing three items?
DSSSB TGT - 2023,
Answer: A
O will be at the top. A stack removes items from the top, last in and first out. The stack from top to bottom is L, M, N, O, P, Q. Removing three items takes away L, then M, then N, and O is left at the top. L is the item removed first, N is removed third and P lies below O, so none of them is on top. Elements are added and removed only at the top, so the order of removal is the reverse of the order of addition.
Please log in or register to report this question.