AnimG LogoAnimG

Discrete Math animation videos

Browse curated Discrete Math animation examples in Computer Science, including reusable Manim scenes, visual proofs, and teaching-ready ideas.

Computer Science ยท 24 animations

Binary Trees โ€” Insert, Search, AVL Balance

Binary Trees โ€” Insert, Search, AVL Balance

Demonstrates binary search tree operations step by step: inserting nodes to build a BST, searching for a value with left/right comparisons shown, detecting an unbalanced tree, and performing an AVL left rotation to restore balance. Height and balance factor labels update throughout.

CAP Theorem

CAP Theorem

Explains the CAP theorem through an animated distributed system with 3 nodes. A network partition is triggered, and the animation shows the trade-off: choosing CP sacrifices availability while choosing AP allows divergence. Real-world systems are labeled with their CAP classification.

Consistent Hashing

Consistent Hashing

Demonstrates consistent hashing on a circular hash ring (0โ€“360 degrees). Server nodes are placed on the ring, keys are assigned clockwise, and the animation shows that adding or removing a server only redistributes a minimal fraction of keys. Virtual nodes are introduced to improve load distribution.

Dijkstra's Shortest Path

Dijkstra's Shortest Path

Visualizes Dijkstra's algorithm on a weighted directed graph with 6 nodes. The animation shows the priority queue (min-heap), greedy node exploration, distance table updates at each step, and the final shortest path tree highlighted in gold.

Dynamic Programming โ€” Fibonacci & Memoization

Dynamic Programming โ€” Fibonacci & Memoization

Contrasts three approaches to computing Fibonacci numbers: naive recursion (exponential, showing repeated subproblems in red), top-down memoization (cached calls return instantly in green), and bottom-up DP table filling. Complexity labels O(2^n) vs O(n) are displayed prominently.

Git Internals โ€” DAG of Commits

Git Internals โ€” DAG of Commits

Visualizes Git's underlying commit DAG structure. Commit objects are shown as circles with abbreviated hash IDs, branches as colored labels pointing to commits, and HEAD as a special pointer. Operations animated include: git commit (new node), git branch (new label), git merge (merge commit with two parents), and git rebase (commits replayed on new base).

Merge Sort โ€” Divide, Conquer, Merge

Merge Sort โ€” Divide, Conquer, Merge

Visualizes the classic merge sort algorithm on an 8-element array [5,3,8,1,9,2,7,4]. The animation shows the recursive divide phase as a tree splitting down to individual elements, then the merge phase rebuilding sorted subarrays from the bottom up. Complexity is displayed as O(n log n).

Quicksort โ€” Pivot Partitioning

Quicksort โ€” Pivot Partitioning

Demonstrates the quicksort algorithm on an unsorted array using in-place pivot partitioning. Shows the two-pointer sweep with elements being classified relative to the pivot, the pivot landing in its final sorted position, and recursive application to subarrays. Displays both average and worst-case complexities.

RSA Encryption

RSA Encryption

Walks through the RSA public-key cryptosystem: key generation from two primes, encryption using the public key, and decryption using the private key. Alice and Bob exchange an encrypted message, demonstrating the one-way trapdoor function. The security relies on the hardness of integer factorization.

TCP Three-Way Handshake

TCP Three-Way Handshake

Animates the complete TCP connection lifecycle between a client and server: the three-way handshake (SYN, SYN-ACK, ACK), data transfer phase, and four-way connection teardown (FIN, ACK, FIN, ACK). Each packet is labeled with its flags and sequence/acknowledgment numbers, and a timeline diagram tracks the full exchange.

Big-O Complexity

Big-O Complexity

Plots growth curves for the six major Big-O complexity classes on a shared set of axes. A ValueTracker animates n growing, showing how quickly each curve diverges. A reference table maps each complexity to example algorithms.

Binary Search

Binary Search

Demonstrates binary search on a sorted array of 16 numbers searching for the value 42. Each step highlights the middle element, eliminates half the array, and a step counter shows the logarithmic efficiency versus linear search.

Bubble Sort

Bubble Sort

Visualizes bubble sort on an array of 8 colored bars of different heights. Adjacent comparisons trigger swap animations highlighted in orange. Pass and swap counters update live. The O(nยฒ) complexity is displayed after sorting completes.

BFS vs DFS Graph Traversal

BFS vs DFS Graph Traversal

Shows an 8-node undirected graph and demonstrates two traversal strategies: BFS spreads level by level using a queue, while DFS dives deep using a stack. Visited nodes are colored and the visit order is displayed for each strategy.

Hash Tables

Hash Tables

Demonstrates hash tables by animating the hash function that maps a key to a bucket index, inserting multiple key-value pairs, performing a lookup, and resolving a collision using chaining.

Recursion & the Call Stack

Recursion & the Call Stack

Animates the recursive computation of factorial(4), showing a visual call stack that grows as recursive calls are made and then unwinds as each frame resolves. The base case is highlighted, and final computed values propagate back up the stack.

Arrays

Arrays

Introduces arrays as a row of numbered boxes. Shows storing values, accessing elements by index, iterating with a moving pointer, and appending an element at the end.

Boolean Logic Gates

Boolean Logic Gates

Introduces AND, OR, and NOT logic gates using standard gate symbols. For each gate, the truth table is animated row by row, with input/output wires lighting up green (1/true) or red (0/false). A bonus NAND gate is shown as the combination NOT(AND).

Conditionals & Loops

Conditionals & Loops

Demonstrates two fundamental control flow structures: the IF/ELSE conditional (is it raining?) and the WHILE loop (counter < 5). An animated flowchart shows each decision diamond, paths, and the loop-back arrow. The counter increments visually on screen.

Binary Numbers

Binary Numbers

Introduces binary numbers using the metaphor of light switches that are either off (0) or on (1). Students see how combinations of 4 switches represent decimal numbers and how counting works in binary from 0 to 3.

Algorithms: Step-by-Step Instructions

Algorithms: Step-by-Step Instructions

Introduces the concept of an algorithm using the relatable example of making a peanut butter sandwich. Each step appears in a flowchart-style sequence, reinforcing that an algorithm is a precise, ordered set of instructions that computers follow exactly.

What is a Computer?

What is a Computer?

An introduction to computers for primary school students (ages 6โ€“11). Shows the core concept of input โ†’ process โ†’ output as a simple pipeline, using everyday examples like a calculator and a video game. Key takeaway: computers take in information, do something with it, and give back a result.

A* Pathfinding

A* Pathfinding

Demonstrates the A* search algorithm on a grid map with obstacles, navigating from source S to goal G. Shows the f=g+h cost function for each cell, contrasting the open set (frontier) and closed set (visited), and how the heuristic guides the search more efficiently than BFS. The final path is highlighted in gold.

B-Trees & LSM-Trees (Database Indexes)

B-Trees & LSM-Trees (Database Indexes)

Contrasts two major database index structures used in production systems. B-trees are shown with multi-key nodes, branching factor, and range scan animation. LSM-trees show the write path from memtable through SSTable levels, and the read path checking multiple levels. Use cases are labeled clearly.