Dijkstra's algorithm a greedy or dynamic programming algorithm?
Dijstra
https://chinese.freecodecamp.org/news/dijkstras-shortest-path-algorithm-visual-introduction/
https://mathweb.ucsd.edu/~fan/teach/202/notes/04greed.pdf
Dijkstra's algorithm a greedy or dynamic programming algorithm?
https://stackoverflow.com/questions/14038011/dijkstras-algorithm-a-greedy-or-dynamic-programming-algorithm
此算法既应用了 贪婪策略, 也应用了 动态规划。
It's greedy because you always mark the closest vertex. It's dynamic because distances are updated using previously calculated values.
Why is Dijkstra’s algorithm considered a greedy algorithm?
https://www.quora.com/Why-is-Dijkstra-s-algorithm-considered-a-greedy-algorithm
贪婪算法定义: 使用启发式策略每个步骤中的局部最优解,期望找到全局最优解。
动态规划定义: 为了解决复杂问题,我们将复杂问题分解为一系列简单子问题的集合, 解决每一个子问题,保存他们的解法结果。
Now that we understand the basics of Dijkstra’s, we can now compare it to greedy or dynamic programming algorithms. The definition of a greedy algorithm: an algorithmic paradigm that follows the problem solving heuristic of making the locally optimal choice at each stage with the hope of finding a global optimum. The definition of a dynamic programming algorithm: a method to solve a complex problem by breaking it down into a collection of simpler subproblems, solving each of those subproblems just once, and storing their solutions.
https://www.quora.com/Is-Dijkstras-Algorithm-a-greedy-algorithm-or-a-dynamic-programming-algorithm
对于最短路问题,DP是一种解法,还可以有其它解法, 但是此问题最优化结构: 通过寻找局部最优化, 产生全局最优化的结果, 这里就对应贪婪的术语。
每步骤的贪婪,可得到全局的最好结果。
从问题域的角度来看, 应该说 “最短路问题”属于贪婪策略可解得范畴;
从具体实现算法Dijkstra来说, 其极具有贪婪算法属性,也有DP属性。
Problems have structure we exploit to design algorithms for them. The shortest path problem is not a “DP problem”. It is a problem that can use techniques such as dynamic programming to solve. This is a common mistake people make; they talk about problems with respect to algorithms instead of the correct way (algorithms with respect to problems). I think a lot of the confusion here is more pedagogical than scientific; how you were introduced to the algorithm. I don’t really know any standard reference texts in areas ranging from Combinatorial Optimization to Analysis of Algorithms that would refer to the algorithm as a dynamic programming algorithm (as it isn’t). For example, the widely used text Algorithm Design by Kleinberg and Tardos most certainly describes it as a greedy algorithm:
Source: https://www.cs.princeton.edu/courses/archive/spring13/cos423/lectures/04GreedyAlgorithmsII-2x2.pdf