Tree walk in order for non-binary trees

Does the term "traversal in order" have a clear meaning for trees wider than binary trees, or does "pre-" and "post-" order the only type of DFS that makes sense? I mean n> 2 children per node.
I think, for n, that even this can mean a transition to the “root” after the children n/2, but is it ever used? What about the odd ones n?

+4
source share
1 answer

Walking around in order will still be well defined only if you explicitly divide the children into children and children.

, , , , (, , , , , ).

, n-ary , .

, : enter image description here

2 , node, :

14, 15, 5, 16, 17, 18, 6, 19, 2, 20, 21, 7, 8, 9, 3, 10, 1, 11, 12, 4, 13

.

+6

Source: https://habr.com/ru/post/1541386/


All Articles