//先序和中序结果创建二叉树
#include <iostream>
#include<vector>
using namespace std;
struct BinaryNode {
int val;
BinaryNode* left;
BinaryNode* right;
};
BinaryNode* createTree(vector<int>pre,vector<int>mid)
{
if (mid.size() == 0)return NULL;//如果输入是空,直接返回
BinaryNode* root = new BinaryNode();
root->val
前序中序建立二叉树
最新推荐文章于 2022-09-12 08:52:15 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)