Most of the time you don't build a stack — your language already has one. This lesson shows the built-in stack in each language, the mistakes people make with them, and then how to build your own stack on a linked list so you know exactly what happens underneath.
Here is the same small job in all four: push some values, then pop until the stack is empty. The values come out reversed.
Members only · free account
The rest of this lesson, with 4 more sections, 2 drawings, a dry-run simulator and code in JavaScript, Python, Java and C++, opens with a free account.
Not ready yet? The Arrays course is free to read, no account needed.
In the rest of this lesson