You are given a binary tree and a node in the tree, your task is to find all the nodes in the binary tree which are at a distance K from that node. These nodes can be downwards [descendants of the node] or upwards.
For example: In this image
http://www.cs.mcgill.ca/~jeromew/comp252/images/Binary_tree.png
The nodes that are at a distance 2 from 7 are 5 (6’s left child), 11, 5 (2’s right child).
This is a coding question.
Function prototype:
void PrintKDistanceNode(Node *root, Node *node, int K)
{
}