1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| typedef struct TreeNode { int data; TreeNode * left; TreeNode * right; TreeNode * parent; }TreeNode; void pre_order(TreeNode * Node) { if(Node == NULL) return; printf("%d ", Node->data); pre_order(Node->left); pre_order(Node->right); } void middle_order(TreeNode *Node) { if(Node == NULL) return; middle_order(Node->left); printf("%d ", Node->data); middle_order(Node->right); } void post_order(TreeNode *Node) { if(Node == NULL) return; post_order(Node->left); post_order(Node->right); printf("%d ", Node->data); }
|