Why my code is giving a segmentation error

@aasif2364
your code have a few errors

  1. do dfs from node 1 not from node 0
  2. resize the list and the visited list by v+1 so that it can store the node v
    https://ide.codingblocks.com/s/624971
    this is the changed code it will work fine if your dout is solved mark it as resolved and rate my experience

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.