Veda Bites are swipeable micro-lessons — each one teaches exactly one
idea. Here's a taste from this kit; the app has the full deck.
💡 Key Idea
Stack: LIFO Principle
Last in, first out—the core rule.
A stack is a linear data structure that follows the LIFO (Last-In, First-Out) principle. The most recently added element is the first one to be removed. Think of a stack of plates: you add and remove from the top only.
↳ Stacks enforce LIFO: the last element added is the first removed.
📖 Definition
Core Stack Operations
Push, pop, peek—the big three.
↳ Push adds, pop removes, peek inspects—all at the top.
⭐ Important Fact
Stack Time Complexities
All operations are O(1).
In a well-implemented stack (using an array or linked list), push, pop, and peek all run in O(1) time. This makes stacks extremely efficient for their intended use.
↳ Stack operations are constant-time, O(1).