Data Structures

Data structures are some of the most foundational knowledge every computer scientist must know. The most simple, of course, is the array: a contiguous series of equally sized blocks of memory which can be easily indexed. Oftentimes using the right data structure can make a hard algorithmic problem much, much easier. Here we showcase three: the stack, the queue, and the heap.

Queue


A queue is what's known as a first in first out (FIFO) data structure. It supports two operations: dequeueing, i.e. removing and retrieving the front of the queue, and enqueueing, i.e. adding to the back of the queue. Try pressing the enqueue and dequeue buttons below to get a feel for this data structure.

Enqueue
Dequeue

Stack


A stack is a last-in first-out (LIFO) data structure. It supports two operations: pushing, i.e. putting a new element into the stack, and popping, i.e. removing the last element from the stack. Try pressing the push and pop buttons to get a feel for how the stack works.

Push
Pop

Heaps


Trees are data structures in which every element contains some number of "child" elements, which the tree can access as its descendants. Heaps are a special type of tree in which either all elements are greater than their children--so called max heaps--or all elements are greater than their children--so called min heaps. In the accompanying illustration, we showcase two fundamental operations of a heap using a max heap--try inserting a random element or extracting the maximum of the heap.

Insert Random Element
Extract Maximum