segmentation fault occur
Kruskal algorithm
It is probably because you have defines unite function after the solve function. And you have not made a function declaration.
i have made changes but still it showing segmentation fault
plzz correct my code
Can you give me the questions link? I’ll try submitting this
sir, it’s from video in a course
How did you know that this is giving a segmentation fault. I do not see any will in the code
try to run it bro in coading block ide
Haven’t you tried submitting it somewhere. Sometimes there are problems with the ide.
but sir output to ana chaiyee na???
same error occur in other compiler too
Okay let me go through in detail
ok sir i think there is a problem in a loop and also explain why in the video we take init(n+1) for 1 indexing and for zero indexing he take init(n) and subtract every vertex by 1 try to explain the logic behind this indexing in union find algorithm
For 1 based indexing we want our values from 1to n inclusive. So it array size must be n+1. Similarly you can understand for zero based indexing
ohk sir got it thanku
https://ide.codingblocks.com/s/284959 It is not giving a segmentation fault now. You initialized the parent array with size n but were accessing par[n].
SO always keep the size of all the arrays and vectors as n+5 atleast.