Implemented Programming Question 5 (Dijkstra's algorithm)