Print all nodes at distance , truncation error

code Link : https://ide.codingblocks.com/s/184203
this my code link , please correct it and specify my mistake

in the buildPreOrderBinary function u are not incrementing the value of I that gived u the error

Also, there will be errors in the o/p formating

i am giving u the corrected code for the truncation error, try out formating the o/p by urself

hey @chhavibansal this link to my code : https://ide.codingblocks.com/s/186162
but than also I am not getting required output in second case , please look into my code correct it and specify error

hi , the logic for printing nodes at distance k is wrong,

like u do not just have to see in the downwards direction , but also a traveral through parent can be seen

i recommend u to go through the following link:

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.