The Complete Guide
CodeCookbook
Interactive, step-by-step visualizations of algorithms and data structures. Learn by watching, not just reading.
Tools
Measure performance and watch algorithms race head-to-head
Configure algorithms, input sizes, and scenarios. Watch real timing curves emerge across millions of elements.
Choose any two algorithms, set the array size, and watch them sort the same array simultaneously. See which finishes first and compare comparisons, swaps, and steps.
Sorting Algorithms
20See how different strategies sort data step by step
Logos Sort
Nine strategies applied in order: tally, gallop, cut at the golden ratio, consult three voices, roll the die, divide into three, recurse the small.
Adaptive Sort
Reads the data before sorting: counting sort for integer ranges, insertion sort for tiny or nearly-sorted inputs, introsort with heapsort fallback otherwise.
Introsort
Quicksort with a safety net: if recursion depth exceeds 2·log₂n, it falls back to heapsort. Small subarrays finish with insertion sort. The basis of std::sort.
Bubble Sort
Compares adjacent pairs and swaps them if out of order. Each pass settles the largest remaining element.
Selection Sort
Finds the minimum of the unsorted region and swaps it to the sorted boundary. O(n) swaps total.
Insertion Sort
Inserts each element into its correct spot in the already-sorted prefix. Fast on nearly-sorted data.
Merge Sort
Recursively divides in half, sorts each half, then merges. Guaranteed O(n log n) in all cases.
Quick Sort
Picks a pivot, partitions around it, and recurses on both sides. O(n log n) average; O(n²) worst case.
Heap Sort
Builds a max-heap, then repeatedly extracts the max to produce sorted output in-place.
Shell Sort
Insertion sort over a shrinking gap — long-range swaps first, fine-tuning last.
Counting Sort
Tallies occurrences of each integer and reconstructs the array. Requires a bounded key range.
Radix Sort
Sorts digit by digit, least to most significant, using counting sort at each position.
Bucket Sort
Scatters elements into buckets, sorts each bucket with insertion sort, then concatenates.
Tim Sort
Detects natural runs, extends short ones with insertion sort, then merges via galloping mode. Python's and Java's built-in sort.
Cocktail Sort
Bidirectional bubble sort — forward pass pushes the max right, backward pass pushes the min left. Faster on partially-sorted data.
Comb Sort
Eliminates turtles (small values near the end) by comparing elements far apart. Shrinks the gap by factor 1.3 each pass.
Gnome Sort
A single pointer advances if neighbors are in order, or swaps and retreats. The simplest possible sorting algorithm.
Pancake Sort
Sorts by prefix reversals only — like flipping stacks of pancakes. Each round places the next-largest element using at most 2 flips.
Cycle Sort
Writes each element exactly once by tracing permutation cycles. Optimal when array writes are expensive.
Odd-Even Sort
Alternates between odd-indexed and even-indexed adjacent swaps. Parallelizes naturally — each phase can run simultaneously.
Data Structures
12Push, pop, enqueue, dequeue — watch every operation live
Stack
Last-In-First-Out. Push and pop from the top of the stack.
Queue
First-In-First-Out. Enqueue at back, dequeue from the front.
Deque
Double-ended queue. Push and pop from both front and back.
Linked List
Nodes connected by pointers. Insert, delete, and traverse.
Binary Heap
Min-heap tree. Insert and extract-min with percolate operations.
Hash Table
Hash function maps keys to buckets. Separate chaining for collisions.
BST
Binary Search Tree. Insert, search, delete, and traversal animations.
Graph
Undirected graph with BFS and DFS traversal step-by-step.
AVL Tree
Self-balancing BST. Every insert/delete triggers LL, RR, LR, or RL rotations to keep balance factors in {−1, 0, 1}.
Red-Black Tree
Self-balancing BST with color bits. Uses recoloring and rotations to maintain 5 invariants, guaranteeing O(log n) height.
Trie
Prefix tree that stores strings character by character. O(m) insert and search where m is the word length.
Segment Tree
Range-query tree. O(log n) range-sum queries and point updates with step-by-step traversal animations.
Tools
8Practice, calculate, and explore algorithms interactively
Cheat Sheet
All algorithms and data structures at a glance — sort by time, space, stability. Filter, print, or bookmark for interview prep.
Flashcards
See an algorithm name, guess the complexity, track your score. Covers all sorting algorithms and data structures.
Algorithm Picker
Stability? Memory constraints? Nearly sorted data? Answer a few questions and get a tailored recommendation with reasoning.
Complexity Calculator
Select a complexity class, enter n, and see estimated milliseconds. Compare all classes side by side in one reference table.
Path Finding
Click to draw walls, drag to set start/end, pick an algorithm, and watch it find a path step by step.
Sound Concert
Each algorithm gets its own oscillator type and pitch range. Start them all together and listen to the chaos resolve into order.
Complexity Quiz
40+ questions, streaks, timer, and a local high score. See an algorithm, guess its Big-O. Covers sorting, data structures, searching, and graph algorithms.
Sorting Network
See how bitonic sort uses a fixed network of comparators to sort in O(log² n) parallel stages with no branching.