Difference between Prim's and Dijkstra's algorithms?

前端 未结 15 1841
既然无缘
既然无缘 2020-12-07 06:53

What is the exact difference between Dijkstra\'s and Prim\'s algorithms? I know Prim\'s will give a MST but the tree generated by Dijkstra will also be a MST. Then what is

15条回答
  •  死守一世寂寞
    2020-12-07 07:34

    Dijkstra's algorithm is a single source shortest path problem between node i and j, but Prim's algorithm a minimal spanning tree problem. These algorithm use programming concept named 'greedy algorithm'

    If you check these notion, please visit

    1. Greedy algorithm lecture note : http://jeffe.cs.illinois.edu/teaching/algorithms/notes/07-greedy.pdf
    2. Minimum spanning tree : http://jeffe.cs.illinois.edu/teaching/algorithms/notes/20-mst.pdf
    3. Single source shortest path : http://jeffe.cs.illinois.edu/teaching/algorithms/notes/21-sssp.pdf

提交回复
热议问题