Evaluation of Dijkstra's Algorithm
Evaluation of Dijkstra's Algorithm
Algorithm Execution:
The algorithm uses a binary heap (priority queue via heapq)
It maintains a dictionary where:
● Keys are vertices
● Values are tuples containing the shortest path distance and the preceding vertex
Correctness Verification:
● The path length at (3,3) is 7, meaning Dijkstra’s algorithm is correctly summing up the shortest
distances.
● The step-by-step path is printed, showing logical progression.
Evaluation of Dijkstra’s Algorithm
3. Evaluate the runtime of Dijkstra as the size of the grid graph increases
4x4 0.000000 5
8x8 0.000000 14
16x16 0.000913 49
2. Key Observations:
Key Observations:
Conclusion:
5. Evaluating the impact of the binary heap APQ versus the unsorted list
APQ.
Key Observations
Conclusion
● The results strongly support using a binary heap for Dijkstra’s algorithm.
● The unsorted list struggles as the graph size grows, leading to exponential slowdowns.
● Why does this happen?
○ A binary heap allows efficient insertions and deletions in O(log n) time.
○ An unsorted list must search for the minimum element in O(n) time for every
extraction.
○ As the graph grows, the heap scales efficiently, while the unsorted list struggles
under increasing load.
For real-world applications where speed matters, the binary heap is the clear winner. The
unsorted list is only useful for small graphs where implementation simplicity is more important
than performance.
Evaluation of Dijkstra’s Algorithm
6. Evaluating a simpler priority queue
Implementation Overview
2. The alternative approach is easier to implement but has a higher overhead
3. The difference in runtime (~30% slower for the alternative approach) is noticeable.
Conclusion
● The standard approach is preferable for performance reasons, particularly for large-scale
graphs.
● The alternative approach is useful when implementation simplicity is more important than
execution time.
Final Thoughts:
● The binary heap is the clear winner for Dijkstra’s algorithm, ensuring fast performance
even on large graphs.
● Using an unsorted list for a priority queue quickly becomes impractical due to its poor
scaling.