I am getting segmentation fault. Please help.
Print all nodes at distance k
@vaishnavtannu
Check the input format correctly. There is no m to be taken as input. So delete line 104 and change line 108 to for(int i = 0; i < n; i++)
Also take cin>>t; after line 121
Please check now. I am still not getting any output.
- Change line 57 to if(root->data == target->data)
- Change line 62 to int leftDistance = printNodesAtDistanceK(root->left, k, target); and line 76 to int rightDistance = printNodesAtDistanceK(root->right, k, target);
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.