Skip to content

Latest commit

 

History

History
21 lines (16 loc) · 675 Bytes

Minimum Spanning Tree.md

File metadata and controls

21 lines (16 loc) · 675 Bytes

Minimum Spanning Tree on undirected graph

Kruskal's algorithm

  • Use greedy approach
  • Sorted edges by weight
  • Apply Union and Find algorithm

Prim's algorithm

  • Invented by Dijkastra and named as Prim's algo as it was already discoved by Prim
  • This is based on captured/discovered/undiscovered approach
  • Start from some vertex
  • treat this vertex as source
  • At each step, there is single structure, which expands slowly
  • Structure remains connected https://leetcode.com/problems/connecting-cities-with-minimum-cost/