46: Averages of levels in a binary tree

Given a binary tree. Calculate the average value on each level of the binary tree

 

Example 1

Input:     1   
          / \  
         5   3 

Output: [1, 4]

Example 2

Input:     1   
            \  
             3 

Output: [1, 3]