Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array.
e.g.
3
/ \
20 9
/ \
15 7
You should output 3, 14.5, 11.
There are 3 lines for inputs.
The first line contains an integer N , which indicates the number of nodes of the binary tree.
The second line is the inorder traversal of the binary tree.
The third line is the preorder traversal of the binary tree.
Note that there are no duplicated integers in the binary tree.
Print the average of each levels in one line.
1. There is an whitespace between each number.
2. There is an whitespace after the last number.
3. There is no need to print newline in the end.
Moreover, for the sake of convenience, show only 3 digits after decimal point of each average numbers of level.
(You can simply use %.3f to display in such way)