Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 7

Prim's Algorithm

on minimum spanning tree

Submitted by:
Darshnik Deep (38150)
Harshal Paliwal ( )
Department of Computer Science,
Suresh Gyan Vihar University
Jagatpura, Mahal sadak yojna.
Project on Prims Algorithm
• Index
• What is minimum spanning
tree.
• Graph
• Algorithm
• About
What is Minimum Spanning Tree?
• Given a connected, undirected graph, a
spanning tree of that graph is a subgraph
which is a tree and connects all the
vertices together.
• A single graph can have many different
spanning trees.
• A minimum spanning tree is then
a spanning tree with weight less
than or equal to the weight of
every other spanning tree.
graph G

Spanning Tree from Graph G


2 2

4 3 4 5

1 1 1
Algorithm for finding
Minimum Spanning Tree

• The Prim's Algorithm


About Prim’s Algorithm
The algorithm was discovered in 1930 by
mathematician Vojtech Jarnik and later
independently by computer scientist Robert C. Prim
in 1957.
The algorithm continuously increases the size of a
tree starting with a single vertex until it spans all the
vertices.
Prim's algorithm is faster on dense
graphs.
Prim's algorithm runs in O(n*n)
But the running time can be reduce
using a simple binary heap data structure
and an adjacency list representation
• Prim's algorithm for finding a minimal
spanning tree parallels closely the depth-
and breadth-first traversal algorithms. Just
as these algorithms maintained a closed
list of nodes and the paths leading to
them, Prim's algorithm maintains a closed
list of nodes and the edges that link them
into the minimal spanning tree.
• Whereas the depth-first algorithm used a
stack as its data structure to maintain the
list of open nodes and the breadth-first
traversal used a queue, Prim's uses a
priority queue.

You might also like