LLMs are pretty good at stuff that an untrained human can do as well. Algorithms and data structures are wayyy to specialized.
I recently asked gpt4 about semiconductor physics - not a chance, it simply does not know.
But for general topics it's really good. For one reason that you simply glossed over - you can ask it specific questions and it will always be happy to answer.
Okay, at least it's not incorrect, there are no lies in this, although I would nitpick two things:
- It doesn't state what the actual goal of the algorithm is. It says "fundamental method used in computer science for finding the shortest paths between nodes in a graph", but that's not precise; it finds the shortest paths from a node to all other nodes, whereas the wording could be taken to imply its between two nodes.
- "infinity (or a very large number)" is very weird without explanation. Dijkstra doesn't work if you put "a very large number", you have to make sure it's larger than any possible path length (for example, sum of all weights of edges would work).
Those nitpicks are something you can ask it to clarify! Wikipedia doesn't do that. If you are looking for something specific and it's not in the Wikipedia article - tough luck, have fun digging through different articles or book excerpts to piece the missing pieces together.
The meme about stack overflow being rude to totally valid questions does not come from nothing. And ChatGPT is the perfect answer to that.
Edit: I'm late, but need to add that I can't reproduce OPs experience at all. Using GPT4 turbo preview, temperature 0.2, the AI correctly describes dijkstras algorithm. (Distance from one node to all other nodes, picking the next node to process, initializing the nodes, etc).
To respond to one of the nitpicks I asked the AI what to do when my "distance" data type does not support infinity (a weak point of the answer that does not require me to know the actual bound to question the answer). It correctly told me a value larger than any possible path length is required.
It also correctly states that Dijkstras algorithm can't find the longest path in a graph and that the problem is NP hard for general graphs.
For negative weights it explains why Dijkstra doesn't work (Dijkstra assumes once a node is marked as completed it has found its shortest distance to the start. This is no longer a valid assumption if edge weights can be negative) and recommends the Bellman-Ford algorithm instead. It also gives a short overview of the Bellman-Ford algorithm.
What's apm?