Courses ›
Data Structures in C
Stacks and queues
Two restricted lists that solve a surprising number of real problems.
12 min read
·
Lesson 4 of 6
·
Pro
Restriction as a feature
A stack is a list where you may only touch one end. A queue is a list where you add at one end and remove from the other. Removing options sounds like a downside. It is not - the restriction is exactly what makes the structure useful, because now every operation is O(1) and the behaviour is predictable.
- Stack: Last In, First Out. The last plate you put down is the first
you pick up.
- Queue: First In, First Out. The college canteen line.
Where you have already used a stack without knowing
The rest of this lesson is Pro
The free lessons of Data Structures in C finish what
they start — read those first if you have not. This one goes further, and it
is part of the paid half.
A pass opens the paid lessons of every course, the mock test papers
and the company-wise series. It ends on its own date; nothing renews by itself.
Get a pass — from
₹29 for 7 days
Already bought one? Log in.