Search⌘ K

What is a Stack?

Understand how stacks work with their Last In First Out ordering, learn core stack operations such as push, pop, and peek, and explore their uses in tasks like undo functions and algorithm implementation to prepare for coding interviews.

Introduction

We are all familiar with the famous Undo option which exists in almost all popular applications. Ever wondered how that works? Well, you store the previous states of your work (which are limited to a specific number) in the memory in such an order that the last one appears first. You can’t really do this with simple lists very efficiently for reasons we will explore in the coming chapters. So this is where the ‘Stack’ data structure comes in handy.

Stacks ...