Which data structure follows the Last In, First Out principle?

Options

  • A. Queue
  • B. Stack
  • C. Linked List
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. Stack

Detailed Explanation

A Stack follows the LIFO (Last In, First Out) principle. The element inserted most recently is removed first. Important stack operations are push, which inserts an element, and pop, which removes the top element. A peek or top operation reads the top element without removing it. Stacks are used in function-call management, recursion, expression evaluation, undo operations, and backtracking algorithms.