Simon Fraser University Pseudocode for A Algorithm Programming Task

ONLY THE SOLUTION FOR (B) IS REQUIRED

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Could you use Dijkstra’s algorithm inside another algorithm to find the shortest path in a graph?Would that be a good idea? a. Write pseudocode for a simple algorithm that uses Dijkstra’s algorithm to find theshortest path between any two nodes in a graph. You can call Dijkstra as functionDijkstra(G, n), where G is the graph, and n is the number of the starting node. What isthe time complexity of this algorithm?

Pseudocode:

1. BEGIN

2. Dijkstra(G, n)

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

3. Repeat for v in G

4. dist[v] = Infinity

5. prev[v] = NULL

6. if v ! = source

7. add v to Queue

end if

end for

8. repeat while Queue is not empty

9. n = min from Q

10. for unvisited node v of n

11. dist1= dist[n]+edgeWeight(n,v)

12. if dist1 < dist[n]

13. dist[v] = dist1

14. prev[v] = v

end ifend for

15. return dist

16. END

b. How could you improve this by not using Dijkstra’s algorithm? Write pseudocode for abetter algorithm. What is its time complexity? Prove or explain why it is a betterreplacement for the algorithm in (a).

Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER