Stacks allow you to store data in an ordered way, where the most recent item that was added to the stack is the next item that can be removed. This is called Last In, First Out, or LIFO. Learn the other key characteristics of the stack's abstract data type in this video.
- [Instructor] Now that we understand the difference…between abstract data types and data structures,…let's talk through what makes…the stack abstract data type unique…and also touch on the basic functionality…we need a stack to have.…Here's a high level definition of a stack.…It holds a collection of items…and the order in which they were added,…and you can only add items to…and remove items from the top of a stack.…If you think of a stack as a stack of pancakes,…you can only add to the top of the pancake stack…and remove from the top of the pancake stack.…
We say this is last-in first-out…because the most recent item you add…is the one that's going to get removed next.…Another way you may hear this phrased is LIFO.…It follows from this example that the order…in which pancakes were added to the stack is preserved.…In other words, you can't take the bottom pancake…without considerable effort and a potential mess.…When it comes to implementing a stack,…our first consideration is whether or not Python…has a built-in data type…
- Abstract types and data structures
- Stacks as a linear abstract data type
- Creating the Stack class and its methods
- Adding items to the top and bottom of a stack
- Creating the Queue class and its methods
- Manipulating items in a queue
- Creating the Dequeue class and its methods
- Adding and removing items from a dequeue
Skill Level Advanced
Learning the Python 3 Standard Librarywith Kathryn Hodge2h 9m Intermediate
What you should know1m 26s
1. Abstract Data Types and Data Structures
2. The Stack
3. The Queue
4. The Deque
Next steps1m 43s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.