Print all nodes sat distance k from a given node not getting submitted

I am not getting where i am getting wrong in 2nd and 4th case because it is now working for the 2 cases.Please help me. code link—> https://ide.codingblocks.com/s/131249