###### Asked in Computer ProgrammingMath and ArithmeticC Programming

Computer Programming

Math and Arithmetic

C Programming

# How does Prim's algorithm work?

## Answer

###### Wiki User

###### August 24, 2008 11:56AM

First a vertex is selected arbitrarily. on each iteration we expand the tree by simply attaching to it the nearest vertex not in the tree. the algorithm stops after all yhe graph vertices have been included.. one main criteria is the tree should not be cyclic.

## Related Questions

###### Asked in Computer Programming, Computer Science

### What is the difference between Prims algorithm Kruskals algorithm and dijktras algorithm?

Well, Dijkstra algorithm is a way to find a path with minimum
weight between 2 vertices's in a weighted graph.
Prims And Kruskal algorithms are algorithms used to find the a
path with minimum weight in a way that you can go from any vertex
to another. Prims And Kruskal Algorithms are some how the same and
both are greedy algorithms, but Prims insiste that the next edge to
be chosen must be an edge with minimum weight connected to the
current fringe whereas kruskal says that the next edge to be chosen
dosent have to be connected to the current set of edges.

###### Asked in Computer Programming

### What is the difference between Prims algorithm and kruskals algorithm for finding the minimum spanning tree of a graph?

Prims And Kruskal Algorithms are some how the same and both are
greedy algorithms, but Prims insiste that the next edge to be
chosen must be an edge with minimum weight connected to the current
fringe whereas kruskal says that the next edge to be chosen dosent
have to be connected to the set of vertices's Already Chosen.

###### Asked in Computer Programming, Electrical Engineering, Computer Science

### What is the importance of analysis in the design of an algorithm?

There are two main reasons we analyze an algorithm: correctness
and efficiency.
By far the most important reason to analyze an algorithm is to
make sure it will correctly solve your problem. If our algorithm
doesn't work, nothing else matters. So we must analyze it to prove
that it will always work as expected.
We must also look at the efficiency of our algorithm. If it
solves our problem, but does so in O(nn) time (or space!), then we
should probably look at a redesign.

###### Asked in Computer Programming, C Programming, The Difference Between

### What is the difference between implementation and algorithm?

An algorithm is a instruction for solving a problem. It is
typically illustrated using prose, pseudo code or flowcharts, but
other methods exist. The algorithm is the "here's how it's going to
work" part of the solution.
An implementation (of an algorithm) is a specific expression of
this algorithm, using a specific programming language or any other
suitable means. The implementation is the "here's how I've done it"
part of the solution.

Load More