Stacks

Projected Time

About 1 hour

Prerequisites

Motivation

Stack is one of the most commonly used data structure along with its opposite relative, queue. Understanding how to implement stack helps you better understand and describe insertion, removal, and organization of data in a sequential order.

Applications of stack includes:

Objectives

Explain what a stack data structure is and show how it is implemented.

Specific Things to Learn

Lesson

Lesson slides
Lesson video

Make sure to mention these things:

Common Mistakes / Misconceptions

Guided Practice

Explain and discuss as a class the steps involved in writing a stack structure, including:

Independent Practice

Try to write a Stack class with the steps discussed as methods:

const Stack = function() {}
  // Constructor

  // Push

  // Pop

  // Size management of stack

  // Output of stack
}

Challenge / Check for Understanding

Find a partner and show each other your own Stack class. Explain how the class you wrote works.

Next, ask each other the following questions:

Supplemental Resources