Computer Science Textbooks Figures - Animated with VisuAlgo

All these Data Structure and Algorithm textbook examples were static figures before.
The exact same examples are now animated with my visualization tool VisuAlgo, with convenient one-click links :).
Also, whenever possible, I will also supply my Competitive Programming 4 textbook implementation of those algorithms.

Last update: Sun, 20 April 2025, 9.30pm.
This page will have gradual updates as soon as I read more CS books and decide to digitise some static pictures.

Introduction to Algorithms (Fourth Edition)

Introduction to Algorithms (Fourth Edition, 2022), authored by Cormen Lieserson Rivest Stein (CLRS), is probably the most well-known Computer Science textbook on algorithm. There are lots of data structures and/or algorithm examples and it will take some time to digitise all of them. Here are a few examples:

Chapter Page Static Figure, now in VisuAlgo (just press 'space' button to play the animation) CPbook Implementation
21.2 592-593 Figure 21.4. The execution of Kruskal's algorithm on the graph from Figure 21.1. kruskal.cpp|py|java
21.2 595 Figure 21.5. The execution of Prim's algorithm on the graph from Figure 21.1.
The root vertex is a( = 0).
prim.cpp|py|java
22.2 618 Figure 22.5. The execution of the algorithm for shortest paths in a directed acyclic graph.
The vertices are topologically sorted from left to right.
This version uses the newest feature of VisuAlgo (curvey edges).
Figure 22.5. The execution of the algorithm for shortest paths in a directed acyclic graph.
This version requires rearranging vertices to avoid overlapping edges.
toposort.cpp|py|java + use the toposort info
22.3 621 Figure 22.6. The execution of Dijkstra's algorithm.
The source s(=0) is the leftmost vertex.
dijkstra.cpp|py|java

Competitive Programming 4

Competitive Programming (Fourth Edition), authored by Steven Halim (myself), Felix Halim, and Suhendry Effendy, focuses more on breadth of data structures and algorithms collections that are typically used in programming competitions such as the International Olympiad in Informatics (IOI) and the International Collegiate Programming Contest (ICPC). This book strongly uses VisuAlgo as both the book and VisuAlgo are created by the same person.

Chapter Page Static Figure, now in VisuAlgo (just press 'space' button to play the animation) CPbook Implementation
2.4.4 115 Figure 2.19*: Segment Tree of A = {18, 17, 13, 19, 15, 11, 20, ∞} and RMQ(1, 3) = 13.
Note that this /segmenttree visualization page is much more up-to-date compared to CP4 (July 2020) version.
segmenttree_ds.cpp|py|java
2.4.4 116 Figure 2.20*: Segment Tree of A = {18, 17, 13, 19, 15, 11, 20, ∞} and RMQ(4, 7) = 11. As above
2.4.4 117 Figure 2.21*: Updating A to {18, 17, 13, 19, 15, 77, 20, ∞}. As above
2.4.4 118 Figure 2.22*: Updating A to {30, 30, 30, 30, 15, 77, 20, ∞}.
Note that the behavior of lazy flag is slightly different from CP4 Jul 2020 version.
As above
2.4.4 118 Figure 2.23*: Updating A to {30, 30, 30, 7, 15, 77, 20, ∞}. As above
8.4.4 423 Figure 8.15*: Illustration of Dinic's Algorithm (BFS) - Part 1, and.
Figure 8.16*: Illustration of Dinic's Algorithm (BFS) - Part 2.

Note that two more edges 5 → 6 and 5 → 7 are added and the layout is edited a bit to enhance the explanation.
maxflow.cpp|py|java
8.6.10 457-458 Figure 8.35 (Left): Steiner Tree Illustrations.
Note that there is an errata in the explanation: For this kind of test case with 3 terminal vertices but NOT on Euclidean Steiner Tree version,
We should run the 'Small-size Instance' solution and cannot assume there is only at most 3-2 = 1 Steiner vertex.
Steiner Tree code is not available yet
9.27 574-576 Figure 9.25: L: Initial Graph, M: Complete Weighted Bipartite Graph; R: Equality Subgraph
Figure 9.26: L: 1st Augmenting Path; M: Stuck; R: Relabel the Equality Subgraph, and
Figure 9.27: L+M: 2nd+3rd Augmenting Paths; R: Max Weighted Perfect Matching

Note that the latest visualization has a clearer explanation than the CP4 written version.
Hungarian code is not available yet

Algorithms Illuminated (Omnibus Edition)

Algorithms Illuminated (Omnibus Edition, 2022), authored by Tim Roughgarden, is an alternative textbook that is similar in nature with CLRS above, i.e., focusing more on analysis of algorithms.

Chapter Page Static Figure, now in VisuAlgo (just press 'space' button to play the animation) CPbook Implementation
10.5.3 229-231 Implementing Insert in O(log n) Time, example of Insert(-5).
Note that all values are negated as the underlying heap is a Binary Max Heap.
BinaryHeapDemo.cpp|py|java
10.5.3 232-233 Implementing ExtractMin in O(log n) Time, example of one call of ExtractMin().
Note that all values are negated as the underlying heap is a Binary Max Heap.
As above
16.2 370-377 (Alternative) O(N) Dynamic Programming for the Max Weighted Independent Set (blue vertices).
Note that this visualization is actually computes Min Weighted Vertex Cover (orange vertices), but these two are dual problems.
UVa10243.cpp|py

Essential Algorithms (Second Edition)

Essential Algorithms (Second Edition, 15 May 2019), authored by Rod Stephens, is a 762-pages thick DSA textbook. We have not read the book in details, but here is one that we found quite interesting due to the written remarks.

Chapter Page Static Figure, now in VisuAlgo (just press 'space' button to play the animation) CPbook Implementation
13 424-425 Figure 13.10: Kosaraju's algorithm traverses the network's links forward and then backward.
In page 425, there is a remarks: "If you still have trouble visualizing how the algorithm works,
you may want to implement it and step through it in a debugger.
You don't have to do that now, just click the provided link :).
UVa11838.cpp|py|java

Algorithmic Thinking (Second Edition)

Algorithmic Thinking, now in its second edition (2024), authored by Daniel Zingaro, contains step-by-step solution explanations for a few programming competition tasks. There are not that many figures, but we will try to digitise as many as possible. Here are two examples.

Chapter Page Static Figure, now in VisuAlgo (just press 'space' button to play the animation) CPbook Implementation
6 209 Figure 6-2: A reversed version of the graph in Figure 6-1 (UVa 1112 - Mice Maze). Dijkstra's from Cell 3 (0-based indexing). As above
8 285-287 Figure 8-5: A max-heap with 91 inserted.
Figure 8-6: A max-heap with 91 moved up.
Figure 8-7: A max-heap with 91 moved up again.
Figure 8-8: A max-heap with 91 moved up yet again.
Figure 8-9: A max-heap with the heap-order violation repaired.
As above
8 288-289 Figure 8-10: A max-heap with 85 extracted.
Figure 8-11: A max-heap with 38 moved down.
Figure 8-12: A max-heap with 38 moved farther down.
As above

A Common-Sense Guide to Data Structures and Algorithms (Second Edition)

A Common-Sense Guide to Data Structures and Algorithms (Second Edition, August 2020), authored by Jay Wengrow, is a beginner DSA textbook, with much more simpler discussions compared to CLRS above. Unfortunately my copy probably has printing errors, with many of the figures missing important labels. Only the following three examples are archiveable.

Chapter Page Static Figure, now in VisuAlgo (just press 'space' button to play the animation) CPbook Implementation
4 38-42 Bubble Sort in Action (Using the example array [4, 2, 7, 1, 3]. SortingDemo.cpp|py|java
5 52-56 Selection Sort in Action (Using the example array [4, 2, 7, 1, 3]. As above
6 64-68 Insertion Sort in Action (Using the example array [4, 2, 7, 1, 3]. As above