It can be done with only one Queue, doing a level traversal and each time we are in a new level we insert a dummy node(can be null)to separate the levels, while doing the traversal we just keep adding the nodes we are inserting and keep the count of how many nodes we have so when we find a null pointer we just divide the current sum by the current count.