A Practical Guide to the Stack Data Structure

Kelyn NjeriKelyn Njeri
1 min read

To help me conceptualize stacks and also some of their functions, I usually think of it as a stack of books or a stack of Jenga bricks as you can see on the cover image above. A stack is a linear data structure that functions on the Last In First Out (LIFO) principle which means that the last element in a stack is the first one to be removed, just like a stack of books.

Stack Implementation in Python

Stack Implementation in Go

Uses of Stacks

  1. It is used to evaluate arithmetic operations.

  2. It is used in backtracking, a recursive algorithm used for solving optimization problems.

  3. It is used for delimiter checking.

  4. It is used to reverse a given set of data.

  5. It is used to process function calls.

0
Subscribe to my newsletter

Read articles from Kelyn Njeri directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Kelyn Njeri
Kelyn Njeri

Senior Software Engineer with a knack for Python, Golang, TypeScript, and Elixir. I am also a bit of a Rust enthusiast. I am excited by all things scalability and microservices. Join me on this journey to becoming a unicorn 10x Engineer.