דלג לתוכן

Lesson 47: First in, first out

English

Wait in line

  • A queue keeps items in the order they arrive. New items join at the back; items leave from the front.
  • This is FIFO: first in, first out, like people waiting at a counter.
  • A stack (lesson 21) is the opposite: LIFO, last in, first out.

Words for this lesson

Word Meaning
queue first in, first out
enqueue add an item at the back: queue.append(x)
dequeue take the item at the front: queue.pop(0)
front / rear the oldest item / the newest item

היכנס או צור חשבון

IGCSE, A-Level & AP