why recursion is not working in my code to collect all the nodes connected directly or indirectly with a given node?

Viewed 9

code snippet that I wrote

I want to insert all the values of nodes that are connected directly or indirectly with a given node 'h' to the vector "collect". In some cases, it gives the correct answer. But other times it gives segmentation falls. Why is it happening?

0 Answers
Related