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

2k Views Asked by At

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.

0

There are 0 best solutions below