6

What is the logic behind the names in-order, pre-order and post-order? Why are they called like that?

  • In-order. Why the word "in", what is it "in"?

  • Pre-order. "Pre", means "previous", but previous what?

  • Post-order. "Post" means "after", but after what?

I know that there are previous threads asking how one traverses a tree using these orders and such. NOTE THAT THAT IS NOT WHAT I'M ASKING HERE SO IT'S NOT A DUPLICATE QUESTION. I'm asking what is the meaning of the names. Why are they called like they are called.

Data
  • 69
  • 4
  • 1
    Hate to reference wikipedia, but go here for a reasonable explanation -- http://en.wikipedia.org/wiki/Tree_traversal – ErstwhileIII Dec 29 '14 at 19:00
  • Possible duplicate of [From where did preorder, postorder and inorder traversal of a tree got its name?](https://stackoverflow.com/questions/13545167/from-where-did-preorder-postorder-and-inorder-traversal-of-a-tree-got-its-name) – Jack Jan 20 '19 at 23:49

1 Answers1

10

To my understanding, the terminology refers to the position where the root node of the argument is processed. Let r be the root of a binary tree with left subtree A and right subtree B. For inorder, the sequence of processing is ArB, for preorder it is rAB and for postorder it is ABr.

Codor
  • 17,447
  • 9
  • 29
  • 56