高强度训练第十八天总结: 二叉查找树: 二叉查找树就是左结点小于根节点,右结点大于根节点的一种排序树,也叫二叉搜索树。也叫BST,英文Binary Sort Tree。 就长下面这吊样 查找步骤 在二叉搜索树b中查找x的过程为: 若b是空树,则搜索失败,否则: 若x等于b的根节点的数据域之值,则查找 ...
分类:
其他好文 时间:
2019-10-02 22:53:28
阅读次数:
129
Leetcode Tree Depth-first Search Given preorder and inorder traversal of a tree, construct... ...
分类:
其他好文 时间:
2019-10-02 21:08:04
阅读次数:
100
题意:给出头结点,让你判断这颗树是不是二叉搜索树。 思路: 很显然,对于一棵二叉搜索树,其左右子树肯定也是二叉搜索树; 因此,递归思路:如果左右子树都是BST,并且该根结点也符合规律(小于左子树的最小结点,小于右子树的最大结点) 递归边界:如果是空节点,那么返回true; 我在实现的时候偷了一点懒; ...
分类:
其他好文 时间:
2019-10-02 21:05:09
阅读次数:
131
题意: 给定一棵树 当前树的答案为 $f[1]^f[2]^f[3]^..^f[n]$ f[i]表示去除掉i点 该树的联通块数量 有m次操作 每次将两个点连一条边 然后再输出该树的答案 题目 题解: 显然一开始的时候 答案为每个点的答案为其度 所以可以处理好一开始的答案 如果将两个点连在一起的时候 那 ...
分类:
其他好文 时间:
2019-10-02 20:48:56
阅读次数:
97
安装 在我的电脑中安装了anaconda,所以我用anaconda来安装,先切换到我要安装的环境下,然后开始安装jupyter 安装完毕后运行jupyter 这个界面不要关闭,然后默认浏览器会打开一个网页,地址为 http://localhost:8888/tree# ,浏览器中的界面长这样 使用 ...
分类:
其他好文 时间:
2019-10-02 20:31:01
阅读次数:
135
111. Minimum Depth of Binary Tree Easy Easy Easy Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the short ...
分类:
其他好文 时间:
2019-10-02 17:02:53
阅读次数:
77
In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the ...
分类:
其他好文 时间:
2019-10-02 14:35:43
阅读次数:
88
$Description$ 一棵树是一个不含环的连通图。 树上两点间的距离是两点间最短路径的长度(边的)。 给你一棵$n$个点的树和一个正整数$k$。找出不同的距离为$k$的点对的数量。注意点对$(u,v)$和$(v,u)$被认为是相同的。 $Input$ 第一行包含两个整数$n$和$k$ $(1≤ ...
分类:
其他好文 时间:
2019-10-02 12:58:29
阅读次数:
71
输入:一个已经排好序的待搜索数组array_to_search,需要查找的数number,查找边界left、right。 输出:number在array_to_search中的位置,若未找到,输出 1。 实现思路 1. 将数组的中间元素array_to_search[middle]与待查找数numb ...
分类:
其他好文 时间:
2019-10-02 11:01:45
阅读次数:
89
110. Balanced Binary Tree Easy Easy Easy Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is d ...
分类:
其他好文 时间:
2019-10-02 10:23:19
阅读次数:
88