首页 > 代码库 > 二叉树的先序、中序、后序的递归与非递归实现

二叉树的先序、中序、后序的递归与非递归实现

#include <iostream>
#include <cstdlib>
#include <stack>

using namespace std;

struct BinTree {
    int data;
    struct BinTree *left;
    struct BinTree *right;
};

struct BinPost {
    BinTree *pTree;
    bool isFirst;
};

void CreateBinTree(BinTree* &root)
{
    int data;
    cin>>data;
    if(data =http://www.mamicode.com/= 0)>

二叉树的先序、中序、后序的递归与非递归实现