filmov
tv
Stack Tutorial | How to implement a Stack from Scratch

Показать описание
Stack Data Structure Tutorial. How to implement a stack from scratch?
Today we will be diving into a data structure called Stack.
Let's imagine you're placing plates on a counter. How would you access the last bowl? To be fair, You can lift everything and take the last one out but if you do it like this: you take the top most bowl and put it aside, then you take the top most bowl again and put it aside, and you keep doing this until the last bowl - then you can say that that is a stack!
Another example are undo/redo operations. Everything you do gets stored inside a stack and when you want to undo that, last thing you did is on the top of the stack waiting for you.
Stack is a linear data structure which follows a particular order in which the operations are performed. The order is often called LIFO - last in first out!
Today we will be diving into a data structure called Stack.
Let's imagine you're placing plates on a counter. How would you access the last bowl? To be fair, You can lift everything and take the last one out but if you do it like this: you take the top most bowl and put it aside, then you take the top most bowl again and put it aside, and you keep doing this until the last bowl - then you can say that that is a stack!
Another example are undo/redo operations. Everything you do gets stored inside a stack and when you want to undo that, last thing you did is on the top of the stack waiting for you.
Stack is a linear data structure which follows a particular order in which the operations are performed. The order is often called LIFO - last in first out!