#K90902. Maximum Depth of a Complete Binary Tree
Maximum Depth of a Complete Binary Tree
Maximum Depth of a Complete Binary Tree
You are given an integer N representing the number of nodes in a complete binary tree and a list of N integers representing the node values in level order. Your task is to calculate the maximum depth of the binary tree.
If N > 0, the maximum depth D of the tree is given by the formula:
If N = 0, the tree is empty and its depth is defined to be 0.
Note: Although the list of node values is provided, you only need to compute the depth based on the number of nodes N.
inputFormat
The input is read from standard input and consists of two lines:
- The first line contains an integer N (0 ≤ N ≤ 105) representing the number of nodes in the binary tree.
- If N > 0, the second line contains N space-separated integers representing the node values of the binary tree in level order.
outputFormat
Output a single integer to standard output which is the maximum depth of the complete binary tree.
## sample7
3 9 20 15 7 0 0
3