Bubble Sort
Repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order.
Choose an algorithm and trace its execution frame by frame. Step at your own pace, inspect memory and pointers, or scrub the timeline.
Repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order.
Repeatedly finds the minimum element from the unsorted suffix and puts it at the beginning.
Builds the final sorted array one item at a time by repeatedly inserting elements into a sorted prefix.
Divide-and-conquer algorithm that divides the array in half, sorts both halves, and merges them back together.
Selects a pivot element and partitions the array into values smaller and larger than the pivot.
Converts the array into a max-heap, then repeatedly extracts the maximum element to the end of the array.
Non-comparison integer sorting algorithm that tallies the frequency of each distinct key.
Sorts keys digit by digit starting from least significant digit using a stable subroutine like counting sort.
Distributes elements into several buckets, sorts each bucket individually, and concatenates them.
Generalization of insertion sort that allows exchanges of far-apart elements using diminishing gap sequences.
Bidirectional variation of bubble sort that traverses back and forth to address turtle elements.
Improves bubble sort by eliminating small values near the end using a shrinking comparison gap with factor 1.3.
Sorts by stepping backward when an inversion is detected and forward when elements are in order.
Hybrid stable sorting algorithm derived from merge sort and insertion sort, optimized for real-world data.
In-place unstable sorting algorithm that minimizes the total number of memory writes.
Sorts an array using only prefix-reversal operations (flipping the top k elements).
Sequentially checks each element of the list until a match is found or the whole list has been searched.
Finds the position of a target value within a sorted array by repeatedly dividing the search interval in half.
Searches sorted arrays by jumping ahead by fixed blocks of √n, then performing linear search.
Estimates target position in uniformly distributed sorted data using linear interpolation formula.
Finds range where element resides by doubling powers of 2, then performs binary search in that bounded range.
Divides sorted range into three equal parts to determine which third contains the target.
Maintains low and high pointers moving inward to find pairs summing to a target in sorted arrays.
Moves two pointers at different speeds (tortoise and hare) to detect cycles or find middle elements.
Maintains a running sum or metric across a window of fixed length k as it slides across an array.
Dynamically expands right edge to satisfy constraints and contracts left edge to find optimal subarrays.
Precomputes cumulative running sums to answer range sum queries in constant O(1) time.
Finds the contiguous subarray with maximum sum in linear time by maintaining a current sum and global max.
Sorts an array of three distinct values (such as 0s, 1s, and 2s) in a single pass with low, mid, and high pointers.
Identifies the candidate element that appears strictly more than n/2 times in O(1) space.
Uses a precomputed failure function (pi table) to avoid re-examining characters that already matched.
Uses rolling hashes to quickly filter out positions that cannot match the search pattern.
Computes longest prefix match lengths (Z-array) for all suffixes of a concatenated pattern string.
Demonstrates overlapping subproblems and shows how tabulation fills values sequentially from base cases.
Fills a 2D table to determine maximum value obtainable without exceeding weight capacity W, tracing back choices.
Constructs 2D DP table comparing string prefixes and traces back diagonal and adjacent transitions.
Computes minimum insertions, deletions, and substitutions needed to transform word1 into word2.
Builds optimal minimum coin counts for every intermediate sub-amount up to the target amount.
Calculates the number of paths from top-left to bottom-right moving only right and down.
Traverses a 2D matrix in spiral order using top, bottom, left, and right boundary pointers.
Places N non-attacking queens on an N×N board using depth-first backtracking and conflict checking.
Fills 9×9 puzzle cells using recursive backtracking, checking row, column, and 3×3 subgrid constraints.
Explores graph vertices layer by layer using a FIFO queue, finding unweighted shortest paths.
Traverses deep along each branch as far as possible before backtracking using a LIFO stack.
Finds single-source shortest paths on weighted non-negative graphs using a priority queue greedy strategy.
Relaxes all edges V-1 times, computing shortest paths and detecting reachable negative weight cycles.
Greedily adds lowest-weight edges that do not form a cycle, using Disjoint-Set Union (Union-Find).
Grows an MST from a starting node by continually adding the cheapest edge connecting the tree to unvisited nodes.
Orders vertices of a DAG linearly using in-degrees and a queue of zero-indegree candidate nodes.
Visits left subtree, root, then right subtree; yields keys in non-decreasing order for BSTs.
Visits root, left subtree, then right subtree; widely used for cloning and serializing trees.
Visits left subtree, right subtree, then root; ideal for bottom-up deletions and subtree metrics.
Explores tree level by level from top to bottom, left to right, using an explicit FIFO queue.
Navigates left if key < node and right if key > node, finding position and grafting new leaf.
Maintains height balance factor within {-1, 0, 1} through LL, RR, LR, and RL rotations.
Visualizes swim (bubble-up) and sink (sift-down) operations with synchronized tree and array representations.
Reverses singly linked list pointers in-place using prev, curr, and next tracking pointers.
Uses slow and fast pointers to detect whether a linked list contains a cycle without extra storage.
Last-In-First-Out data structure where elements are pushed and popped exclusively from the top.
First-In-First-Out data structure where elements join at the rear and exit from the front.
Resolves hash key collisions by storing conflicting elements in linked lists at each bucket index.
Evicts least recently accessed items in O(1) time by coordinating a hash map and a doubly linked list.
Selects the maximum number of mutually compatible activities by greedily picking each next activity with the earliest finish time.
Maximizes total knapsack value by greedily packing items in decreasing order of value density, taking fractional portions as needed.
Computes the greatest common divisor of two integers by repeatedly replacing the larger number with the division remainder until zero.
Identifies all prime numbers up to N by iteratively crossing out composite multiples of each discovered prime on a 6×6 grid.
Counts set bits in a binary number in O(k) steps using n & (n - 1) to extinguish the lowest set bit on each iteration.