Greedy algorithm is used to solve a problem with a heuristic way, In many problems, a greedy strategy does not usually produce an optimal solution, but nonetheless a greedy heuristic may yield locally optimal solutions that approximate a globally optimal solution in a reasonable amount of time.

But sometimes it could yield a optimal solution when the problem could be fracted into some Subitem. For example Kruskal’s Minimum Spanning Tree Algorithm use the greedy

Kruskal Algorithm

the process of Kruskal Algorithm

1. Sort all the edges in non-decreasing order of their weight.
2. Pick the smallest edge. Check if it forms a cycle with the spanning tree formed so far. If cycle is not formed, include this edge. Else, discard it.
3. Repeat step#2 until there are (V-1) edges in the spanning tree.

相关文章:

  • 2021-05-04
  • 2021-12-31
  • 2021-06-25
  • 2021-07-12
  • 2021-05-26
  • 2021-03-31
  • 2019-03-04
  • 2021-12-27
猜你喜欢
  • 2021-06-28
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-06
  • 2021-07-22
相关资源
相似解决方案