Skip to content

Vimtoooo/The-Stack-Data-Structure

Repository files navigation

The Stack Data Structure

A stack is a simple algorithm which is used in our everyday tasks, such as listening to music or web browse history.

How it Works:

This data structure follows the "last in, first out" order, where the first element that was inserted into this particular stack will be the last element to exit it (since every other element has been added on top of it), and if an element was added at last, it will then be the first out of that stack (because that element was added at the top of the stack).

Main Operations:

This algorithm consists of five main operations:

  1. Push: Adds an element to the top of the stack;
  2. Pop: Removes an element from the top of the stack;
  3. Peek/Top: Return the element at the top of the stack, without removing it;
  4. Size/Len: Return the number of elements of that stack;
  5. isEmpty: Verify if the stack is currently empty.

Norms and Guardrails:

  • Every time you create any data structure, you must plan on what and how to handle the elements of the data structure internally. One of the most popular ways is with an array or a container, since we will be inserting/appending these elements into some sort of storage type...

About

How the stack algorithm works.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages