Stack

Definition

A Stack is a data structure where elements are inserted into and removed from the head of the container.

An example of a data stack. Source: https://en.wikibooks.org/wiki/Data_Structures/Stacks_and_Queues

Motivation

  • Sequential

  • Limited access

  • Last-In First-Out (LIFO) access

  • Linear

  • When might I actually use this?

Attributes

  • top
  • is_empty
  • size

Operations

  • push(item)
  • pop()