






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
THIS ASSIGNMENT WILL GUIDE YOU THE DETAILS OF PRIM'S ALGORITHM IN OREDR TO SOLVE THE PROBLEM OF MINIMUM SPNNING TREE.
Typology: Assignments
1 / 12
This page cannot be seen from the preview
Don't miss anything!







ABSTRACT
ALGORITHM
#include<stdio.h> #include<stdlib.h> int a,b,u,v,n,i,j,ne=1; int visited[10]={0},min,mincost=0; int cost[10][10]; void main() { printf("\nEnter the number of nodes:"); scanf("%d",&n); printf("\nEnter the adjacency matrix:\n"); for(i=1;i<=n;i++) for(j=1;j<=n;j++) { PROGRAM:
In prim's algorithm using an adjacency matrix representation time requires is O(n^2) ● However, this running time can be greatly improved further by using binary heaps to implement finding minimum weight edges in the algorithm's inner loop. ● If the input graph is represented using adjacency list, then the time complexity of Prim’s algorithm can be reduced to O(E log V) with the help of binary heap. ● Worst case time complexity: Θ(E log V) using priority queues. ● Average case time complexity: Θ(E log V) using priority queues. ● Best case time complexity: Θ(E log V) using priority queues. ● Space complexity: Θ(E + V) TIME AND SPACE COMPLEXITY:
CONCLUSION :