So far I've read traversal techniques $(Pre-Order, In-Order, Post-Order)$ on binary trees. But In exam I've thrown up with a question, which requires me to find in-order traversal of a ternary tree. I got confused, Is there any generalized steps that we can follow to find traversals for any $m-ary$ tree.

  • 1
    $\begingroup$ Maybe $1$st-subtree, root, $2$nd-subtree, root, $3$rd-subtree, root, $\cdots$, $m-1$th-subtree, root, $m$th-subtree. It depends on your purpose whether to process the root node every time. $\endgroup$ – hengxin Jan 10 '15 at 8:14
  • 1
    $\begingroup$ For there to be an in-order traversal of a tree, there must be some order on every node's children (see 2-3 trees for an example). Then you can just perform a traversal as you would for a binary tree but visit the children in order. $\endgroup$ – James Evans Jan 11 '15 at 4:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.