Stack
A linear data structure that follows the Last-In-First-Out (LIFO) principle.
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["Stack"]:::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;
🧠 Knowledge Check
1 / 1
🧒 Explain Like I'm 5
A stack is like a pile of cafeteria trays. You can only take the tray that's on top, and if you put a new tray down, it goes on top of the others. The last tray you put down is the first one you'll pick up.