Implementation example of binary tree data structure in Java
•
Java
Let's look at a specific exercise practice:
The topic constructs a binary tree according to the pre order traversal sequence of binary tree, such as 7, - 7,8, #, - 3,6,9, - 5, #, and traverses it with pre order, middle order and post order
code
Depth of binary tree
The following is the implementation of the recursive algorithm to realize the binary tree. The idea is that if it is empty, its depth is 0, otherwise, its depth is equal to the maximum value of the depth of the left subtree and the right subtree plus 1:
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码