What is wrong with this function? What is the correct solution?
public static void sumat(Node n,int k){
int level=-1,sum=0;
LinkedList queue=new LinkedList<>();
queue.add(root);
while(!queue.isEmpty()){
Node rn=queue.remove();
sum=sum+n.data;
if(rn.left!=null){
queue.add(rn.left);
}
if(rn.right!=null){
queue.add(rn.right);
}
}
System.out.println(sum);
}