Machine-translated by Google. Questions are authored in English.
Top

Discussion

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.

TopL
M
N
O
P
BottomQ

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?

  • A.O
  • B.L
  • C.N
  • D.P

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.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.