Height of the tree(data structure)

Height of the tree(data structure)

The height of a tree is the length of the path from the tree's root node to any of its leaf nodes. The height of a null tree is zero, with only one node is one.

Depth of the tree

As it's the distance from the root node. e.g. depth of the root node is 0, the depth of a node directly connected to the root node is 1, and so on.

Code to print level-wise node at depth

public void printAtLevelK(TreeNode<Integer> root, int k) {
        if(root == null) {
             return;
       }if(k == 0) {
         System.out.println(root.data);
          return;
       }
      for (int i = 0; i<root.children.size(); i++) {
         printAtLevelK(root.children[i], k-1);
      }

}