- #2056
- javascript-algorithms
Potential Inefficiency and Missed Priority Updates in Dijkstra's Algorithm Implementation
In the Dijkstra algorithm, when a shorter path to a neighbor is found, the neighbor's priority in the priority queue should be updated regardless of whether it is already present in the queue.
In this code, the priority is only changed if queue.hasValue(neighbor) returns true. However, if a neighbor is not yet in the queue, it is added; but if it's already present, the code changes its pri
07/05/2025 1