Please debug the code

was trying to implement Search function in Binary Tree and if the key exist in node, I wanted to return that node. But it’s returning NULL. Please check code.

Hi @ksalokya
I have made a few changes in ur code… its working fine now https://ide.codingblocks.com/s/612339

Thanks a lot. May I know the reason why my code wasn’t working ?

u are unnecessarily making things complicated…
findingKeyNode(root->left,key); these are without any return… secondly if NULL if being returned u are not checking it while printing… what would NULL->data print

alright you can close this thread!

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.