Dhrxv
Dhrxv

Reputation: 43

Time Complexity of (Minimum Spanning Tree) Prim's Algorithm

When we implement this algorithm using adjacency matrix and without using priority queue, the time complexity comes out to be O(V^2), where V is the total no. of vertices and E is the total no. of edges.

But when we implement it using priority queue(using binary heap) and adjacency list, the time complexity comes out to be O((V + E)*logV).

How is this T.C. better than O(V^2) as in worst case E = O(V^2) ?

I am not able to get it. Please clarify my doubt.

Upvotes: 1

Views: 2174

Answers (0)

Related Questions