スタック

最後に追加された要素が最初に削除されるLIFO構造。

A stack is an abstract data type that serves as a collection of elements with two principal operations: 'push' (adds an element) and 'pop' (removes the most recently added element). It is essential for managing function calls, undo mechanisms, and expression parsing.

        graph LR
  Center["スタック"]:::main
  Rel_queue["queue"]:::related -.-> Center
  click Rel_queue "/terms/queue"
  Rel_array["array"]:::related -.-> Center
  click Rel_array "/terms/array"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧠 理解度チェック

1 / 1

🧒 5歳でもわかるように説明

パンケーキの山を想像してください。新しいパンケーキを一番上に乗せ、一番上のパンケーキから食べます。最後に乗せたものが最初に食べられます!

🤓 Expert Deep Dive

スタックオーバーフローは再帰がメモリ制限を超えると発生します。末尾呼び出し最適化はスタックの成長を排除します。ロックフリースタック(Treiber Stack)は並行アクセスのためにCASを使用します。

📚 出典