Which data structure follows the "First-In, First-Out (FIFO)" principle?

2024

Which data structure follows the "First-In, First-Out (FIFO)" principle?

  1. A.

    Stack

  2. B.

    Queue

  3. C.

    Hash Table

  4. D.

    Tree

Attempted by 1084 students.

Show answer & explanation

Correct answer: B

Answer: Queue

Explanation: A queue follows the First-In, First-Out (FIFO) principle — the first element enqueued is the first one dequeued.

  • Example: A line of customers — the first customer to join the line is the first served.

  • Contrast: A stack uses Last-In, First-Out (LIFO), where the most recently added element is removed first.

Explore the full course: Coding For Placement