Choose a queue or a stack
Distinguish first-in-first-out work from last-in-first-out work and handle an empty structure.
In this lesson
- It starts with a question. Should a help queue and an undo history remove items from the same end?
- The idea you will find. A queue removes the oldest waiting item; a stack removes the newest. — First in, first out suits a fair arrival line. Last in, first out suits undoing the latest action before earlier ones. Neither is universally better. Removing from an empty structure needs an explicit empty result or message.
- How you learn it. By doing: putting things in order, matching.
- Length. 8 short steps. Progress saves on this phone.
Part of Solve everyday computing problems
Handle event records, find an item, organise work and test a rule using local, interactive models.