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 VisuAlgo :).

Last update: Thu, 10 April 2025, 11.50pm.
Stay tuned, this page will have a LOT of updates in the next few days...

Introduction to Algorithms (Fourth Edition)

Introduction to Algorithms, now in its fourth edition, authored by Cormen Lieserson Rivest Stein (CLRS), is probably the most well-known Computer Science textbook on algorithm. In this page, I (Prof Halim), will gradually digitise more and more example figures that can already be animated in the corresponding VisuAlgo page. Whenever possible, I also supply my Competitive Programming 4 textbook implementation of those algorithms.

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 (VisuAlgo does not have curve edges yet).
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, now in its 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
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

Essential Algorithms

Essential Algorithms, authored by Rod Stephens, is a 762-pages thick DSA textbook.

Chapter Page Static Figure, now in VisuAlgo (just press 'space' button to play the animation) CPbook Implementation
13 424 Figure 13.10: Kosaraju's algorithm traverses the network's links forward and then backward. UVa11838.cpp|py|java

Algorithmic Thinking (Second Edition)

Algorithmic Thinking, now in its second edition, authored by Daniel Zingaro, contains step-by-step solution explanations for a few programming competition tasks.

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

A Common-Sense Guide to Data Structures and Algorithms

A Common-Sense Guide to Data Structures and Algorithms, authored by Jay Wengrow, is a beginner DSA textbook, with much more simpler discussions compared to CLRS above.

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