i ve Q which ask me to write method called nodelevel(int k ) which returns how many nodes in level k..
and i write a code but i dont know what is wrong with it ???
public nodelevel(int k){
if(root == null)
return 0;
else
return getnodelevel(root, 1);
}
private int getnodelevel(TreeNode root, int k){
if(root == null)
return 0;
else
return level +getnodelevel(root.left, k) + getnodelevel(root.right,k);
}
could u help me plz