C++二叉树(4.12)
标题树的前中后序遍历以及深度根据前中序遍历求后序遍历二叉搜索树的建立
树的前中后序遍历以及深度
struct node{
int p,l,r;
}q[1000001];
int d[100001];
void depth(int root,int v){
d[root]=v;
if(q[root].l!=-1)depth(q[root].l,v+1);
if(q[root].r!=-1)depth(q[root].r,v+1);
}
void pre(int u){
原创
2021-04-12 20:31:07 ·
59 阅读 ·
0 评论