Segmentation fault


Get the segmentation error dry run is working fine for the leave node

got main a mistake at starting root==NULL

can we like this instead of return 0 we can return 1 from the target node to their and check if 1 == k then print the rootnodee else go the rightsubtree

@Vikaspal
yes the mistake was checking if root==NULL.
Yes you can do like that.

If your doubt is solved now, then please mark this doubt as resolved.

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.