On teaching things

August 24, 2024

I distinctly remember thinking Dijkstra's algorithm was hard to understand when I first learned about it in my Algorithms class when studying Computer Science in college.

I also distinctly remember thinking Dijkstra's algorithm was easy to understand when I revisited it while solving LeetCode's Network Delay Time.

Now, I havent't gained any IQ points and Dijkstra's algorithm certainly hasn't changed either.

So what was the differene between my initial attempt and the retry? Understanding the abstractions "all the way down".

As Feynman says, "If you want to master something, teach it". I believe this is because, to explain something, you must explain it in terms of something else. So, you must first understand that "something else". This pattern repeats recursively until you reach your "base case" abstraction. The axiom.

Once you have a mental model of the whole thing, you can walk others through it, from top to bottom or the other way around. You've learned.

So, what exactly is Dijsktra's algorithm? What are the fundamental basic ideas that you have to understand first and in what order to teach them?

We could start with memory, or is that too "far down"? Well, it depends. How much does the student know? We might have to start with electricity, work our way up to the transistor, then memory, then array-based data structures, then the queue, then a priority queue, then graphs, then graph traversal and only then we'll be able to say something like: Dijkstra is -just- a depth-first search where our queue is a priority queue.