pls check the approach else send your approach
Stack ms=new Stack<>();
ms.push(root);
int level=1;
Stack cs=new Stack<>();
while(ms.size()>0){
root=ms.pop();
System.out.println(root.data);
if(level%2==0){
for(int i=root.child.size();i>=0;i++){
Node child=root.child.get(i);
cs.push(child.data);
}
}
else{
for(int i=0;i=root.child.size();i++){
Node child=root.child.get(i);
cs.push(child.data);
}
}
if(ms.size()==1){
ms=cs;
cs=new Stack<>();
level++;
System.out.println();
}
}