Code for optimised LCA gives segmentation fault error.. please help!

Hi, I made code for the LCA through the lecture but can’t find the problem in the code…
code link --> https://ide.codingblocks.com/s/222454

@anmol1911
Please see this rectified code

Hi, even though we made the two tree nodes and called the function… still there is no output…
only bfs(root) function is printing out the tree

Hey @anmol1911
I checked your logic it was incorrect at several places and also way too complex
Please check out the solution here and modify your approach accordingly

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.