

1. Two nodes may have the same value associated with it.
2. Average of any level is computed as the sum of the values of all the nodes at that level divided by the number of nodes at that level.
3. You will be given the 'ROOT' node of the binary tree.
4. You need to print the floor value for each average. For example, if the average of node values at some level is 3.5 then you have to print 3.
The first line of the input contains a single integer 'T', representing the number of test cases.
The first line of each test case contains a single integer 'N' denoting the number of nodes in the tree.
The second line contains the values of the nodes of the tree in the level order form ( -1 for NULL node)
Consider the binary tree

The input of the tree depicted in the image above will be like :
1
2 3
4 -1 5 6
-1 7 -1 -1 -1 -1
-1 -1
Explanation :
Level 1 :
The root node of the tree is 1
Level 2 :
Left child of 1 = 2
Right child of 1 = 3
Level 3 :
Left child of 2 = 4
Right child of 2 = null (-1)
Left child of 3 = 5
Right child of 3 = 6
Level 4 :
Left child of 4 = null (-1)
Right child of 4 = 7
Left child of 5 = null (-1)
Right child of 5 = null (-1)
Left child of 6 = null (-1)
Right child of 6 = null (-1)
Level 5 :
Left child of 7 = null (-1)
Right child of 7 = null (-1)
The first non-null node (of the previous level) is treated as the parent of the first two nodes of the current level. The second non-null node (of the previous level) is treated as the parent node for the next two nodes of the current level and so on.
The input ends when all nodes at the last level are null (-1).
For each test case, print 'X' space-separated values where 'X' is the number of levels in the given binary tree, where the 'i'th integer will denote the average of node values at the 'ith level.
You don't need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10^2
1 <= N <= 10^4
1 <= data <= 10^9
Time Limit : 1 sec
The fact that we need to find the average at each level clearly indicates the need to do a level order traversal of the given tree. So we will run a BFS using a FIFO queue and compute the average at each level.
Here is the algorithm :
Example :