ONLY THE SOLUTION FOR (B) IS REQUIRED
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)
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).