
树
empty_coder
这个作者很懒,什么都没留下…
展开
-
二叉树——最大叶子间距
题目:结点编号从0开始,然后给出每个结点左右子树的编号,其中-1表示为NIL,求最大叶子间距 方法一: 方法有点糙,就是求得任意两个结点的间距,从而可得最大叶子间距 1 . 建树 const int N = 10005; typedef struct { int parent; int lchild, rchild; }BT; BT bt[N]; int n; int ro...原创 2018-03-14 18:06:58 · 776 阅读 · 0 评论 -
树的遍历
YES 题目:已知二叉树中序、后序,求其层次遍历 //已知中序、后序,求层次遍历 #include <cstdio> #include <iostream> #include <string> #include <queue> using namespace std; //const int LEN = 105; typedef struct...原创 2018-03-14 11:30:34 · 216 阅读 · 0 评论