Question: A n-tree where each node contains any no of nodes. Print the nodes in level order and each level must contain a line with a gap

Solution: Take two queues Q1, Q2
//each time in any queues only the nodes belong to one level will be present
//hence print all the queue nodes and print new line
enque root into Q1

while Q1!=empty
print node->data and enque the childs of all nodes in Q2

print("\n");
now process Q2,
while Q2!=empty
print node->data;
enque childs of each node in Q1.

print("\n");

if(Q1.empty() and Q2.empty())
break;//we have processes whole tree.