Notes

Source: 📖 Problem Solving with Algorithms and Data Structures using Python 4.4

Date: 2021-10-28


Operations of a stack

  • push(item) adds a new item to the top of the stack.
  • pop() removes the top item from the stack and returns it.
  • peek() returns the top item of the stack without removing it – the stack remains unchanged.
  • is_empty() is a boolean function to check if the stack is empty.
  • size() returns the number of items in the stack.

See also: