On the binary tree traversal (preorder traversal, in order traversal, postorder traversal)

  • Preorder: root - left his son - the son of the right (about root)

  • Preorder: Left son - root - Right Son (root left and right)

  • Postorder: left son - the son of the right - the root (about root)

Normally this will remember.

Then MY Great God to the sentence: "I do not remember."

Remember the words can be understood: preorder root first, preorder root, the subsequent traversal root in the post, he left his son never greater than the right son

Now look at a map

This graph traversal:

Preorder: 4,251,637
4.2.5 ...... Root left and right Well this is understandable, but why is behind 1?
We put 425 seen as a whole, then 637 seen as a whole. 425 is left son (left subtree) 1 637 1 is the right son. Kazakh.

Preorder: 1245367
best appreciated traversal, 1, 245 left son, 2, 4 left son, the right son 5, the right son, 367, 3, 6 left son, the right son 7.
You can understand it.

Postorder: 4526731
using the above method to push.

Guess you like

Origin www.cnblogs.com/Areds/p/12141929.html