-->
当前位置:首页 > 题库

PROGRAMMING:Binary search tree

Luz5年前 (2021-05-10)题库455
For an infinite full binary sort tree (as shown in the figure), the node numbers are 1, 2, 3. For a subtree with X root, the node with the smallest number can be obtained from the left node down to the last layer; Along the right node down to the last layer, you can get the node with the largest number of the subtree. Now the question is "in a subtree with X root, what are the minimum number and maximum number of nodes?". Please give the answer.
![ POJ2309.jpg](~/ca75f2a3-d6c9-49b2-ae85-d78f251ddc1f.jpg)
###Input format:
The first line of input gives the number of test cases, an integer n. In the following N lines, each line gives an integer x (1 < = x < = $$2 ^ {31} $$- 1), which represents the number of the root of the subtree.
###Output format:
Output n lines, and the i-th line gives the answer to the i-th question.
###Input example:
```in
two
eight
ten
```
###Output example:
```out
1 15
9 11
```







answer:If there is no answer, please comment