Key Concepts

Review core concepts you need to learn to master this subject

Stack overflow

Every stack has a size that determines how many nodes it can accommodate. Attempting to push a node in a full stack will result in a stack overflow. The program may crash due to a stack overflow.

A stack is illustrated in the given image. stackA.push(xg) will result in a stack overflow since the stack is already full.

Stacks: Python
Lesson 1 of 1
  1. 1
    You have an understanding of how stacks work in theory, so now let’s see how they can be useful out in the wild — with Python! Remember that there are three main methods that we want our stacks t…
  2. 2
    The stack’s push() and pop() methods are our tools to add and remove items from it. pop() additionally returns the value of the item it is removing. Keep in mind that we can only make modification…
  3. 3
    With stacks, size matters. If we’re not careful, we can accidentally over-fill them with data. Since we don’t want any stack overflow, we need to go back and make a few modifications to our methods…
  4. 4
    It’s time to add a couple helper methods. Helper methods simplify the code we’ve written by abstracting and labeling chunks of code into a new function. Here’s an example: # Adding “!” without …
  5. 5
    Nice work — you’ve built out a Stack class that can: - add a new item to the top via a push() method - remove an item from the top and returns its value with a pop() method - return the value of…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo