getting segmentation fault
My code
Cycle detection using bfs
hi @Prankur-Tewari-2574939259288733 , there are some small mistakes in your code :
- at line 49 :: g.addEdge(3,4); , you can’t have 4 as a node as you have declared v as 4 thus the nodes you can have in your graph are 0,1,2 and 3 , and accessing l[4] will cause seg fault
2, your isCycle function is returning true when cycle is not present and false when it it , so correct that
here i have corrected your code : - https://ide.codingblocks.com/s/241623
1 Like
thank you sir.so stupid of me of doing it blindly and not debuging it
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.