Skip to content
← Back to glossary

スタックStack

Learn in the textbookFundamentals of Data Structures

DefinitionA stack (スタック) is a data structure that stores data as if piling it up and takes out the most recently added item first, which is called last in, first out (後入れ先出し, LIFO).

ExplanationStoring an item is called a push and taking one out is called a pop, and both always happen at the single top position. The Back button in a web browser, which steps back through pages starting from the one you just viewed, is an everyday example of this behavior.

AnalogyThink of a pile of books on a desk. New books go on top and you also pick them up from the top, so the last book you put down is the first one you get back.

Memory hookThe word is the same stack as in haystack: a heap of things piled one on another.

Related past-exam questions(5 questions)