Print a node at distance k from root

Given a root of a tree, and an integer k. Print all the nodes which are at k distance from root.
For example, in the below tree, 4, 5 & 8 are at distance 2 from root.
1
          /   \
        2      3
      /  \    /
    4     5  8

Comments

  1. Will try to solve it.

    However you did not say anything about this following solutions (Gussa hone ki Emoticon hogi)

    Binary tree is a sum tree or not

    I would also like to have your comments on this, please,

    Some Screenshots of my Expression Based Scientific Calculator

    Tic-Tac-Toe Game

    ReplyDelete

Post a Comment

Popular posts from this blog