Which data structure follows the "First-In, First-Out (FIFO)" principle?
2024
Which data structure follows the "First-In, First-Out (FIFO)" principle?
- A.
Stack
- B.
Queue
- C.
Hash Table
- 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.