intmain() { BiTree T; // 构造一棵二叉树 cout << "Input binary tree elements in order: (note: '.' means empty tree)\n"; if (!CreateBiTree(T)) { cout << "Space allocate error!\n"; return0; } cout << "------------------Binary Recursion Traverse----------------------\n"; cout << "Binary Tree First Order Traverse:\n"; PreOrderTranRecursion(T, TreeTransOperator); cout << endl << "Binary Tree Middle Order Traverse:\n"; InOrderTranRecursion(T, TreeTransOperator); cout << endl << "Binary Tree Post Order Traverse:\n"; PostOrderTranRecursion(T, TreeTransOperator);
cout << endl << "------------------Binary NonRecursion Traverse-------------------\n"; cout << "Binary Tree First Order Traverse 1:\n"; PreOrderTranverse_1(T, TreeTransOperator); cout << endl << "Binary Tree First Order Traverse 2:\n"; PreOrderTranverse_2(T, TreeTransOperator); cout << endl << "Binary Tree Middle Order Traverse 1:\n"; InOrderTranverse_1(T, TreeTransOperator); cout << endl << "Binary Tree Middle Order Traverse 2:\n"; InOrderTranverse_2(T, TreeTransOperator); cout << endl << "Binary Tree Post Order Traverse 1:\n"; PostOrderTranverse_1(T, TreeTransOperator); cout << endl << "Binary Tree Post Order Traverse 2:\n"; PostOrderTranverse_2(T, TreeTransOperator); cout << endl; return0; }
/* One Example: Input binary tree elements in order: (note: '.' means empty tree) A B C . . D E . G . . F . . . ------------------Binary Recursion Traverse---------------------- Binary Tree First Order Traverse: A B C D E G F Binary Tree Middle Order Traverse: C B E G D F A Binary Tree Post Order Traverse: C G E F D B A ------------------Binary NonRecursion Traverse------------------- Binary Tree First Order Traverse 1: A B C D E G F Binary Tree First Order Traverse 2: A B C D E G F Binary Tree Middle Order Traverse 1: C B E G D F A Binary Tree Middle Order Traverse 2: C B E G D F A Binary Tree Post Order Traverse 1: C G E F D B A Binary Tree Post Order Traverse 2: C G E F D B A */