Stacks
Last updated
What is Stacks?
A stack is a linear data structure that follows a particular order in which the operations are performed. The order may be LIFO (Last In First Out) or FILO (First In Last Out). Mainly three basic operations are performed in the stack:
Push: adds an element to the collection.
Pop: removes an element from the collection. A pop can result in stack underflow if the stack is empty.
Peek or Top: returns the top item without removing it from the stack.
The basic principle of stack operation is that in a stack, the element that is added last is the first one to come off, thus the name "Last in First Out".
Free resources to learn Stacks
- ArticleLeetcode
- VideoStacks
- VideoStack Data Structure Tutorial
- VideoPython Stacks
More in stage 5: Basic Data Structures
Stacks: common questions
Can I learn Stacks in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Stacks in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this Stacks tutorial for beginners?
It is lesson 22 of 107 in the free Data Structures & Algorithms roadmap, in stage 5, Basic Data Structures. If you are new to Data Structures & Algorithms, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.