- Home
- Data Structures
Data Structures
How data is organised in memory — arrays, stacks, queues, linked lists, trees, heaps, hash tables and graphs — and why the right structure makes programs fast.
Arrays & Strings
The most basic data structure — a row of boxes in memory. See why reading any element is instant but inserting in the middle is slow.
Stack
A pile of plates you can only touch from the top. Learn push, pop and peek — and why all three are O(1).
Queue
First come, first served. See how enqueue and dequeue work — and why the circular queue is so clever.
Linked List
A chain of nodes connected by pointers. Watch insertion, deletion and the famous "reverse a linked list" happen one arrow at a time.
Binary Search Tree (BST)
A tree where smaller values go left and bigger values go right — so every search throws away half of the tree. Insert, search, delete and traverse it in 3D.
Binary Heap & Priority Queue
A tree that always keeps the smallest value on top — stored secretly inside a plain array. See both views change together in 3D.
Hash Table
The data structure behind dictionaries and maps — find anything in O(1) on average. See hashing, collisions, chaining and linear probing in 3D.
Trie (Prefix Tree)
A tree that stores words letter by letter, so words with the same beginning share a path. The secret behind autocomplete.
AVL Tree
A binary search tree that rebalances itself with rotations, so it never becomes a slow straight line. Watch LL, RR, LR and RL rotations in 3D.
Red-Black Tree
A self-balancing BST that colours every node red or black. Insertions fix themselves with a recolouring or at most two rotations.
Segment Tree
Answer "what is the sum of a[l..r]?" in O(log n) — even while the array keeps changing. Build, query and update it in 3D.
Fenwick Tree (Binary Indexed Tree)
Prefix sums and single-element updates, both in O(log n), using one array and the lowest set bit of each index.
Disjoint Set (Union–Find)
Keep track of which items belong to the same group — and merge groups — in almost constant time. See union by rank and path compression in 3D.
Graph Representation
How a computer actually stores a graph. Compare the adjacency matrix and the adjacency list side by side as you add edges.
Monotonic Stack (Next Greater Element)
Keep a stack in sorted order and answer "what is the next bigger value?" for every element in a single pass.
Bloom Filter
A tiny bit array that says "definitely not here" or "probably here". It saves huge amounts of memory at the price of rare false positives.
About Data Structures
Data structures decide how fast a program can be. Each lesson turns one structure into a 3D model you operate yourself: push onto a stack, enqueue into a circular queue, rotate an AVL tree, hash keys into buckets or query a segment tree, and watch memory change one step at a time. A monotonic stack and a Bloom filter show two clever tricks built from simple parts. Every lesson pairs the model with a plain-English explanation, pseudocode, Python and C++ code, a Big-O table and a short quiz.