Understanding the Call Stack

Understanding the Call Stack


Warmup

  • What is a stack trace?

Data Structures

  • Abstract model for organizing data
  • Models relationships between data
  • Models inserting and accessing data
  • Can model other things, for example:
    • searching
    • deleting

Common Data Structures

  • Linked List
  • Binary Tree
  • Graph
  • Heap
  • Stack

Stacks

  • Fundamental Data Structure in computer science
  • A Stack is the opposite of a Queue
  • Follows “first-in-last-out” semantics
  • Important point about a stack: Things on top of the stack cover or hide things on the bottom – you can’t see or access lower elements while there is a top element

Terminology

  • Top - Most recently added element (sometimes people will say “bottom” if they are envisioning the stack growing from top down)
  • Pushing - adding a new element to the top of the stack
  • Popping - removing the top element from the stack

The Call Stack

  • Represents each method called as an element on the stack.

Explorations

See lesson plan.


Check for Understanding

  • What is the Stack data structure? What are the rules of interacting with a Stack?
  • What is The Call Stack? How does it work?
  • What is a return value, in terms of The Call Stack?
  • When an error occurs, how does Ruby create the Stack Trace?

Lesson Search Results

Showing top 10 results