Typedef struct btree {
ELMTYPE DATA; // Assume first as int
Struct btree * lchild, * rchild;
Btree;
Recrusive recursive
Order
Void Preorder (btree * bt) {
Printf ("% D / T", BT-> DATA);
Preoder (BT-> LCHILD);
Preorder (bt-> rchild)
Return ;;
}
Order
Void MIDORDER (BTREE * BT) {
MIDORDER (BT-> LCHILD);
Printf ("% D / T", BT-> DATA);
MIDORDER (BT-> rchild);
Return;
}
Resequence
Void PostOrder (btree * bt) {
PostORDER (BT-> LCHILD);
Postorder (bt-> rchild);
Printf ("% D / T", BT-> DATA);
Return;
}
Change the left and right sub-tree position of the binary tree
Void Exchange (btree * b) {
BTree * temp;
IF (bt! = null) {
Temp = bt-> LCHILD;
Bt-> lchild = bt-> rChild;
BT-> rChild = Temp;
Exchange (BT-> LCHILD);
Exchange (bt-> rchild);
}
}