Both Prim's and Kruskal's algorithms have a time complexity of _______.

  • O(log n)
  • O(n log n)
  • O(n)
  • O(n^2)
Both Prim's and Kruskal's algorithms have a time complexity of O(n log n), where 'n' is the number of vertices in the graph. This is because they both rely on sorting the edges, and sorting dominates the overall time complexity.
Add your answer
Loading...

Leave a comment

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