What is the next node of the python binary tree?
This article introduces you what is the next node of the python binary tree, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.
The next node that requires the middle order traversal, because the middle order traversal is first left, then root, then right.
Determine whether the node has a right subtree.
If so, the next node must be the leftmost point of the right subtree.
If not, it can be divided into two cases: 1 the node is the left child of the parent node, then the next node is the parent node
2 if the node is not the left child of the parent node, let's find the parent node of the parent node until the node is the left child node of the parent node, and return empty if it does not exist
Focus on writing down 2
While (node.next! = null) {
If (node.next.left = = node) {
Return node.next
}
Node = node.next
}
On the python binary tree what is the next node to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.