Binary tree traversal pre-order, in-order, post-order

Binary trees often encounter the problem of traversal. The traversal is divided into pre-order, in-order and post-order. The difference between these three traversals lies in the order of the root nodes:

Preorder: root left right

Middle order: left root right

Postorder: left and right roots

First, let's see how to manually list the order of traversal:

Preface: ABCDEFGHK

中序:B D C A E H G K F 

Sequence: DCB HKGFEA

The key method of manually writing the sequence is to write the nodes in the order of front, middle and post, and then fill in layer by layer;

Guess you like

Origin blog.csdn.net/daida2008/article/details/99361630