Neo & Byte · #3 · Stack vs queue

Worst Line Ever

Four-panel comic. In a coffee line Byte arrives last and is served first, while the first customer grows a beard. Neo says it is not a line but a stack, and the sign now reads: last in, first out.

Transcript

  1. Panel 1. Barista: “Newest customer? You're up!” Byte: “Me?”
  2. Panel 2. Byte: “I love this line!” First in line: “I was here on Monday.”
  3. Panel 3. Neo: “That's not a line. That's a stack.”
  4. Panel 4. Sign: “STACK: LAST IN, FIRST OUT” First in line: “First in, last out…”

Actually…

A queue serves in order of arrival, first in, first out (FIFO), like a fair coffee line. A stack serves the newest item first, last in, first out (LIFO), like a pile of plates. Stacks run undo, the call stack and depth-first search; queues run print jobs and breadth-first search.

See it step by step

In the VisiGrab app, push, pop, enqueue and dequeue play out step by step. App Store · Google Play