The definition of the binary tree is a recursive definition. The definition and difference between the full binary tree and the fully binary tree. Typedef struct btreenod {elemType Data; Struct btreenode * lc; struct btreenode * rc;} BNode; bnot;
1, the predecessor algorithm of the binary tree VOID Preorder (bt == null) {if (bt == null) return; Else {VIT (BT); if (bt-> lc! = Null) Preorder (BT-> LC); IF (bt-> rc! = null) Preorder (BT-> RC);}} 2 -> lc! = Null) inorder (bt-> lc); Visit (bt); if (bt-> rc! = Null) inorder (bt-> rc);}} 3, the rear sequence algorithm of the binary tree VOID PostOrder (BNODE * BT) {if (bt == null) return; else {if (bt-> lc! = null) PostOrder (bt-> lc); if (bt-> rc! = null) Postorder (bt-> RC); Visit (bt);}}
Three traversal sequences can be obtained from the binary tree. The binary tree can be reconstructed by two traversal sequences.
××× generate binary tree ××× void create_binary_sort_tree (bNode ** proot) {BNODE * P, * q; ELMTYPE KL INT I, N; * proot = NULL; Printf ("INTPUT N:"); scanf (" % D ", & n); for (i = 0; i