Suggest an editImprove this articleRefine the answer for “How does a stack differ from a queue?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)A **stack** and a **queue** differ in the order elements are processed: a stack works on the LIFO principle (last in, first out), while a queue works on the FIFO principle (first in, first out). **Key point:** in a stack, adding and removing happen at one end, while in a queue, adding happens at the tail and removing at the head.Shown above the full answer for quick recall.Answer (EN)ImageThe main difference is in the order elements are processed: - A **stack** works on the **LIFO (Last In, First Out)** principle: last in, first out. Example: a stack of books, to take the bottom one, you need to remove the ones on top. - A **queue** works on the **FIFO (First In, First Out)** principle: first in, first out. Example: a line at a store, whoever got there first is served first. By operations: - In a **stack**, adding and removing happen **at one end** (the top). - In a **queue**: **adding happens at the tail**, and **removing happens at the head**. In short: a stack is like a "history of actions", a queue is like a "waiting line".For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.