What is the time complexity of both Prim's and Kruskal's algorithms?

  • O(E log V)
  • O(E^2)
  • O(V log E)
  • O(V^2)
The time complexity of Prim's algorithm is O(E log V), and the time complexity of Kruskal's algorithm is also O(E log V), where 'V' is the number of vertices and 'E' is the number of edges in the graph. Both algorithms achieve this complexity by using efficient data structures to manage the edges and prioritize the minimum-weight edges.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *