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.
Loading...
Related Quiz
- The Ford-Fulkerson algorithm relies on the concept of _______ to incrementally improve the flow.
- In selection sort, what is the main operation performed in each iteration?
- Explain how the Floyd-Warshall algorithm can efficiently handle graphs with negative edge weights without negative cycles.
- Consider a scenario where a company needs to process large amounts of data through a series of matrix transformations for machine learning tasks. Discuss how Matrix Chain Multiplication can improve the efficiency of this process.
- Associativity plays a key role in optimizing Matrix Chain Multiplication by _______.