There are some errors in your program. In the if condition you wrote if(visited[i] == 0) to check a visited node, it will actually check for an unvisited node. You have to use if(visited[i] == 1) instead. Additionally this program won't output a minimum spanning tree always. It may output simply a spanning tree. Additionally, there is no provision to check whether there is a path from a node to itself. All such paths have to be excluded before starting the operation.
After executing the error will occurs main.c: In function 'main': main.c:22:5: warning: implicit declaration of function 'prims' [-Wimplicit-function-declaration] 22 | prims(n,cost); | ^~~~~ main.c: At top level: main.c:26:6: warning: conflicting types for 'prims' 26 | void prims(int n,int cost[10][10]) | ^~~~~ main.c:22:5: note: previous implicit declaration of 'prims' was here 22 | prims(n,cost); | ^~~~~
@@dollysharma2602 #include int c[10][10],vi[10]={0},i,j,u,v,k=1,n,m,min,t,cost=0,s; int main() { printf("Enter the number of vertices and edges = "); scanf("%d%d",&n,&t); for(i=1;i
#include int a, b, u, v, n, i, j, ne=1; int visited[10] = {0}, min, mincost=0, cost[10][10]; void main() { clrscr(); printf(" Enter the number of nodes:"); scanf("%d", &n); printf(" Enter the adjacency matrix: "); for(i=1; i
#include int a, b, u, v, n, i, j, ne=1; int visited[10] = {0}, min, mincost=0, cost[10][10]; void main() { clrscr(); printf(" Enter the number of nodes:"); scanf("%d", &n); printf(" Enter the adjacency matrix: "); for(i=1; i
Wahh sir wahh , super Sir , The Best Code Of Prims in TH-cam and Internet , thank You Sir
There are some errors in your program. In the if condition you wrote
if(visited[i] == 0) to check a visited node, it will actually check for an unvisited node. You have to use if(visited[i] == 1) instead.
Additionally this program won't output a minimum spanning tree always. It may output simply a spanning tree.
Additionally, there is no provision to check whether there is a path from a node to itself. All such paths have to be excluded before starting the operation.
Thank you Shafi for the correction.
Chatgpt
Explained very clearly.
Beautifully explained Sir.... thank you
Sir your logic is may be correct but u miss the bracket to close❤
Thank you chandan ,I will look into it
thank u sir💌
Thankyou sir
it is not producing a minimum spanning tree it is only producing a spanning tree
... How to convert this is into MST ?
Dinesh mail me the program to girishraosalanke@rvce.edu.in . i will go thru it and reply asap
Sir, my code also not producing mst
How to convert into MST sir please help .
U just wrote it sir..where is the explanation?
Do refer video no 45 ( the previous one) in the same playlist for the explanation of prims algorithm.
@@datastructuresalgorithmsby7411 sir there it is explained how to write in theory
There is no explanation of logical implementation of the program
Does this code run in turbo c++
You an ediot ?
After executing the error will occurs
main.c: In function 'main':
main.c:22:5: warning: implicit declaration of function 'prims' [-Wimplicit-function-declaration]
22 | prims(n,cost);
| ^~~~~
main.c: At top level:
main.c:26:6: warning: conflicting types for 'prims'
26 | void prims(int n,int cost[10][10])
| ^~~~~
main.c:22:5: note: previous implicit declaration of 'prims' was here
22 | prims(n,cost);
| ^~~~~
Mail me the code to girishraosalanke@rvce.edu.in , i will debug and send you back the code
Bro, if your code run please help me
@@dollysharma2602 #include
int c[10][10],vi[10]={0},i,j,u,v,k=1,n,m,min,t,cost=0,s;
int main()
{
printf("Enter the number of vertices and edges =
");
scanf("%d%d",&n,&t);
for(i=1;i
@@shivam637q Thanks
@@shivam637q Can I talk to u please from any source .
Use less and not running in c
#include
int a, b, u, v, n, i, j, ne=1;
int visited[10] = {0}, min, mincost=0, cost[10][10];
void main()
{
clrscr();
printf("
Enter the number of nodes:");
scanf("%d", &n);
printf("
Enter the adjacency matrix:
");
for(i=1; i
#include
int a, b, u, v, n, i, j, ne=1;
int visited[10] = {0}, min, mincost=0, cost[10][10];
void main()
{
clrscr();
printf("
Enter the number of nodes:");
scanf("%d", &n);
printf("
Enter the adjacency matrix:
");
for(i=1; i
If your code run help me please my code didn't give mst
@@dollysharma2602 hmm , check this code, or paste your code in chatgpt and ask him to solve errors
Sir your logic is may be correct but u miss the bracket to close❤