package tree; public class Printnodesatkdistancefromroot { /** * 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…