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

Options

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

Correct Answer (Detailed Explanation is Below)

B. Queue

Detailed Explanation

A Queue follows the FIFO (First In, First Out) principle. The element that enters the queue first is normally removed first. The main operations are enqueue, which inserts an element, and dequeue, which removes an element. Queues are commonly used in CPU scheduling, printer spooling, buffering, breadth-first search, and task management. Variations include circular queues, priority queues, and deques.