Master Algorithms & Data Structures Visually
AntInLoop is a free interactive computer science platform featuring 106 algorithm visualizers, 27 data structure visualizers, 11 step-prediction games, narrated walkthroughs in 4 languages (English, Arabic, Russian, Chinese), and code implementations in C++, Python, Java, and JavaScript.
Popular Algorithms
- Bubble Sort Algorithm — Bubble Sort is a simple, stable, in-place comparison sorting algorithm that repeatedly compares adjacent elements and swaps them if they are in the wrong order. (Demo | Code)
- Heap Sort Algorithm — Heap Sort is an in-place comparison sorting algorithm that builds a binary max-heap in O(n) time and repeatedly extracts the maximum element to achieve guaranteed O(n log n) time. (Demo | Code)
- Merge Sort Algorithm — Merge Sort is a stable, divide-and-conquer sorting algorithm with a guaranteed O(n log n) time complexity in all cases, ideal for linked lists and external sorting. (Demo | Code)
- Radix Sort Algorithm — Radix Sort is a non-comparison sorting algorithm that sorts integers or fixed-length strings digit by digit using a stable subroutine such as Counting Sort. (Demo | Code)
- Linear Search Algorithm — Linear Search sequentially scans each element of a list until it finds the target value or reaches the end, requiring no prior sorting. (Demo | Code)
- Binary Search Algorithm — Binary Search is a divide-and-conquer search algorithm that halves the search interval on every step to locate a target or boundary in a sorted or monotonic domain in O(log n) time. (Demo | Code)
- Ternary Search Algorithm — Ternary Search divides a search interval into three parts using two midpoints, primarily used to find the maximum or minimum of a unimodal function in O(log n) time. (Demo | Code)
- Exponential Search Algorithm — Exponential Search finds a target in a sorted or unbounded array in O(log i) time by doubling the probe index until passing the target, then running Binary Search on the final bracket. (Demo | Code)
- Jump Search Algorithm — Jump Search locates a target in a sorted array by jumping ahead in fixed blocks of size sqrt(n) and then performing a linear scan within the candidate block. (Demo | Code)
- Fibonacci Search Algorithm — Fibonacci Search locates a target in a sorted array in O(log n) time by dividing the search range using Fibonacci numbers, using only addition and subtraction instead of division. (Demo | Code)
- Interpolation Search Algorithm — Interpolation Search improves on Binary Search for uniformly distributed sorted arrays by estimating the target position proportionally, achieving O(log log n) average time. (Demo | Code)
- Breadth-First Search (BFS) Algorithm — Breadth-First Search explores a graph level by level using a FIFO queue, guaranteeing the shortest path in terms of edge count in unweighted graphs. (Demo | Code)
- Depth-First Search (DFS) Algorithm — Depth-First Search explores a graph as deeply as possible along each branch before backtracking, powering cycle detection, connected components, topological sorting, and bridge finding. (Demo | Code)
- Topological Sort Algorithm — Topological Sort produces a linear ordering of vertices in a Directed Acyclic Graph (DAG) such that every directed edge u -> v places u before v, implemented via Kahn's BFS or DFS post-order. (Demo | Code)
- Dijkstra's Algorithm — Dijkstra's Algorithm computes single-source shortest paths in graphs with non-negative edge weights using a greedy min-heap relaxation strategy. (Demo | Code)
- Bellman–Ford Algorithm — The Bellman–Ford algorithm computes single-source shortest paths in graphs with negative edge weights and detects reachable negative-weight cycles in O(V * E) time. (Demo | Code)
Popular Data Structures
- disjoint-set — A Disjoint Set (DSU) partitions elements into non-overlapping sets and extends cleanly to Weighted/Potential DSU (tracking relative offsets or parity) and Rollback DSU (supporting undo).
- adjacency-list — An Adjacency List stores a dynamic list of outgoing neighbors for each vertex, using optimal O(V + E) memory and powering nearly all modern sparse-graph algorithms.
- adjacency-matrix — An Adjacency Matrix stores a graph as a V x V grid where entry (u, v) holds the edge indicator or weight, giving O(1) edge lookups and powering Floyd–Warshall and matrix walk counting.
- binomial-heap — A Binomial Heap is a mergeable priority queue composed of a forest of heap-ordered Binomial Trees mirroring the binary representation of n, supporting O(log n) merge and O(1) amortized insert.
- fibonacci-heap — A Fibonacci Heap is a lazy mergeable priority queue using circular doubly linked root lists and cascading cuts to achieve O(1) amortized insert, merge, and decrease-key, and O(log n) amortized extract-min.
- bloom-filter — A Bloom Filter is a space-efficient probabilistic bit-array data structure that tests set membership in O(k) time with zero false negatives and a tunable, low false-positive rate.
- hash-set — A Hash Set stores unique elements backed by a hash table, providing O(1) expected membership testing, insertion, and deletion for deduplication and fast lookups.
- skip-list — A Skip List is a probabilistic multi-level linked list that adds randomized express lanes on top of a sorted linked list, achieving O(log n) expected search, insert, and delete without tree rotations.
- b-tree — A B-Tree is a self-balancing multi-way search tree that packs hundreds of sorted keys per node to match disk pages and CPU cache lines, guaranteeing shallow O(log_t n) height for databases and filesystems.
- red-black-tree — A Red-Black Tree is a self-balancing Binary Search Tree using 1 color bit (red/black) per node to guarantee height <= 2 log2(n + 1) and O(log n) worst-case search, insertion, and deletion with O(1) rotations.
- avl-tree — An AVL Tree is a strictly height-balanced Binary Search Tree where every node's left and right subtree heights differ by at most 1, guaranteeing O(log n) worst-case search, insertion, and deletion via rotations.
- suffix-tree — A Suffix Tree is a compressed Trie of all suffixes of a string, built in linear O(n) time via Ukkonen's algorithm to answer pattern matching and repeated substring queries in O(m) time.
Interactive Algorithm Games
- BFS Game — Practice Breadth-First Search by predicting the next visited node in real time using FIFO queue traversal rules.
- DFS Game — Practice Depth-First Search by predicting the next visited node and recursive backtracking steps across graphs.
- Dijkstra's Algorithm Game — Master Dijkstra's shortest path algorithm by predicting priority-queue extractions and edge relaxations on weighted graphs.
- Floyd-Warshall Game — Practice all-pairs shortest paths by predicting which distance matrix entries update at each intermediate vertex k.
- KMP String Matching Game — Master Knuth-Morris-Pratt pattern matching and the LPS prefix table by predicting matches and fallback jumps.
- Sieve of Eratosthenes Game — Practice prime number generation by predicting the next composite multiple crossed out by the Sieve of Eratosthenes.
- Suffix Array Game — Learn suffix array construction by predicting the lexicographical ordering of string suffixes step by step.
- Sparse Table Game — Practice building a Sparse Table and answering O(1) Range Minimum Queries using overlapping power-of-two intervals.
- Union-Find (DSU) Game — Practice Disjoint Set Union (DSU) operations including path compression and union by rank interactively.
- GCD Game — Practice the Euclidean Algorithm by predicting every modulo transition when computing the Greatest Common Divisor.
- LCM Game — Two-phase interactive math game: compute GCD via the Euclidean algorithm, then derive the Least Common Multiple.