How to get the last child node of the tree structure

I don"t know how to describe the seed nodes, which are those under the child nodes that have no child nodes (what exactly is the node, would you please correct it for me?).

as shown in the figure, the red box marks the child nodes that need to be obtained:

clipboard.png

is there a good way to get it?

Let"s not mention the method of

PS: traversing all nodes and then determining whether the node has children or not. Is there anything more efficient or skillful?


this kind of node is called a leaf node!

  • if it is a sequentially stored complete binary tree, then the second half of the nodes are leaf nodes.
  • if it is an index tree, you can build an index to the leaf node to reduce the number of traverses.
  • if it is an ordinary tree (without any special place), it can only be traversed, and there is no other method
Menu