The time complexity of both Prim's and Kruskal's algorithms is _______.

  • O(E log V)
  • O(n log n)
  • O(n)
  • O(n^2)
The time complexity of both Prim's and Kruskal's algorithms is O(E log V), where 'E' is the number of edges and 'V' is the number of vertices in the graph. Both algorithms use data structures like heaps or disjoint-set to efficiently select and process edges, resulting in this time complexity.
Add your answer
Loading...

Leave a comment

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