If a picture is worth 1000 words, an animation is worth even more!
Fully understanding an algorithm can be hard, and it is helpful to be able to reason about it in from multiple perspectives. Having a way to visualise an algorithm in progress can be particularly helpful in gaining an understanding of its overall flow. This higher-level view can then be combined with the nitty-gritty details to form a deep understanding of what is happening in totality. You may well find that you need to move between the “forest” and the “trees” views several times before full grokking finally occurs.
Visualising the 100 Doors Algorithm
For example, if you have attempted the 100 Doors Programming Challenge, you may well have had trouble at first trying to picture what was required, and/or being confident that your solution was correct.
Now check out an animation of the problem here. It is likely that after doing so you will have a deeper, more confident understanding of the problem, from a high-level view, which can then inform your actual coded solution. Credit for this p5.js based animation goes to Neil Southin.
Visualising Linear Search
Another algorithm the mechanics of which become very obvious with an animation is Linear Search. The idea is that we check each element in a list or array to determine if it is our target element.
You can run the animation here: https://compucademy.net/linear-search/
Visualising sorting Algorithms
Sorting algorithms are an important part of most Computer Science syllabuses and studying them is great way to develop your algorithmic thinking skills.
There are many different sorting algorithms, and they very considerably in terms of their efficiency. Some of the most common are:
- Bubble Sort
- Selection Sort
- Insertion Sort
- Merge Sort
- Quick Sort
Getting to understand how these sorting algorithms work, and how they differ from each other, can be quite a challenge, and being able to watch animations of them in action is extremely useful.
One great place to find these animations is VisualAlgo.net.
As an Amazon Associate I earn from qualifying purchases.
Visualising Graph Algorithms
Another very important category of algorithm is graph algorithms. Here we are discussing graphs of the type consisting of vertices and edges. To be able to visualise the flow of algorithms like Depth-First Search, Breadth-First Search, Dijkstra’s Shortest Path Algorithm and many more, is immensely helpful in gaining a deep understanding of how they work. It can often take quite a lot of deep thought to truly understand these algorithms, and animations can make that understanding come more quickly.
You can find animations of many graph algorithms also at VisualAlgo.net.
This article has extolled the benefits of watching animations of algorithms to deepen your understanding of how they work, particularly at a high-level view in terms of flow.