A small problem encountered when traversing multi-tree
When traversing a multi-tree, If you traverse sub-nodes under a non-node, you must stop them in time !!! Otherwise, not only O () is increased, but also child nodes are increased repeatedly.The following is a small logic written by myself, with the node being 0 => all groups, followed by a training class => term => lesson
The result is as follows:
Because I am stupid, I think about it carefully and find the Algorithm Vulnerability: when traversing the third-level node (semester), if it does not belong to its parent node, it will still traverse its child nodes (class hours), and will repeatedly Add the child nodes of the semester node, resulting in repeated child nodes
Therefore, a simple solution is implemented: skip this step when traversing to non-child nodes.
The result is normal!
Let's take a look at the small problems encountered at work and record them. We hope to avoid these problems next time and help us.