Given a root of a tree, and an integer k. Print all the nodes which are at k distance from root.
Read full article from Print nodes at k distance from root | GeeksforGeeks
void
printKDistant(node *root ,
int
k)
{
if
(root == NULL)
return
;
if
( k == 0 )
{
printf
(
"%d "
, root->data );
return
;
}
else
{
printKDistant( root->left, k-1 ) ;
printKDistant( root->right, k-1 ) ;
}
}