Prim's Algorithm Time Complexity?

Even though the heap saves you from searching through the array, it slows down the "update" part of the algorithm: array updates are O(1), while heap updates are O(log(N)).

Even though the heap saves you from searching through the array, it slows down the "update" part of the algorithm: array updates are O(1), while heap updates are O(log(N)). In essence, you trade speed in one part of the algorithm for speed in another. No matter what, you'll have to search N times.

However, in dense graphs, you'll need to update a lot (~V^2), and in sparse graphs, you don't. Another example off the top of my head is searching for elements in an array. If you're only doing it once, linear search is the best - but if you do lots of queries, it's better to sort it and use binary search every time.

From the Introduction to Algorithms (Carmen) Time= Θ(V)·T(EXTRACT-MIN) + Θ(E)·T(DECREASE-KEY) T(EXTRACT-MIN) T(DECREASE-KEY) Total 1. Array O(V) O(1) O(V^2) 2. Binary heap O(lgV) O(lgV) O(E lgV) 3.

Fibonacci heap O(lgV) O(1) O(E + VlgV) Using different data structures causes different time complexities.

I think you read it wrong to some degree. For dense graphs, the article talks about using Fibonacci heaps with time complexity O(E + V log V), which is significantly better.

But even so, as E->V^2, the time complexity reaches O(V^2+Vlog(V)) which is greater than O(V^2). – kevmo314 Apr 4 '09 at 20:30 -1 sorry. Kevmo314's comment explains why.

– j_random_hacker Apr 6 '09 at 6:34 1 O(V^2+Vlog(V)) == O(V^2) That should be obvious after taking an algorithms course... – ephemient Apr 6 '09 at 17:35 My main point was that he kevmo314 read the article wrong to some degree. The article says that Fibonacci heaps are used in graphs dense enough that E = w(v). The article does not mention using Prim's algorithm for denser graphs, it mentions Fibonacci heaps.

Dense enough that E=w(V) not E=w(V^2). – Robert Lamb Apr 14 '09 at 4:28.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions