This post is completed by 1 user

  • 0
Add to List

80. Find Nodes at Distance X from Root in a Tree

Objective: - Given Binary Tree, Print all the nodes which are X distance from the root

Example :

Nodes at X distances from root


  • Do the preorder traversal, and pass x as a parameter.
  • While going down, at each level, keep reducing the x by 1
  • When x = 0, this means you have reached the nodes that are at x distance from the root, Print them.


Nodes at 3 distance from root :
 6 7 9