#T466. 查找二叉树
查找二叉树
Description
Given a binary tree, perform an in-order traversal to find the node with value x and indicate its position in the sequence.
For example: In the illustrated binary tree, the in-order traversal sequence is: 29, 12, 8, 15, 23, 5, 10. Searching for 15 returns 4, indicating that 15 is the fourth node in the in-order traversal sequence.
Input Format
The first line contains an integer n, representing the number of nodes in the binary tree, where n ≤ 100. The second line contains the value x to be searched for.
The following lines provide the node data: the first column lists the values of each node (all unique), the second column lists the left child node indices, and the third column lists the right child node indices.
Output Format
Output the position of the searched node in the in-order traversal sequence.
Source
CodesOnline
(The original text was minimal, so the translation is straightforward with the same formatting preserved. The comma after "Hint" was removed as it didn't serve a clear purpose in English.)