码迷,mamicode.com
首页 >  
搜索关键字:binary trees    ( 12390个结果)
java学习--java.lang包中常用的类
java.lang包中的类是不需要import的 基本数据类型的包装类 包装类的使用相差不大,使用方法则以Integer为例 属性: MAX_VALUE 最大值 MIN_VALUE 最小值 构造方法: Integer t1 = new Integer(123); 将int构造成Integer Int ...
分类:编程语言   时间:2018-08-26 12:33:53    阅读次数:180
LeetCode 114. Flatten Binary Tree to Linked List
树里的 divide and conquer 感觉和 post order traversal 就是一个东西,反正都是递归。 下面方法返回了 root ,也可以不返回,直接用 flatten 自己递归也行。 时间复杂度 O(nlogn) 空间复杂度 O(h) ...
分类:其他好文   时间:2018-08-26 01:10:35    阅读次数:121
109. Convert Sorted List to Binary Search Tree
和 148. Sort List 一样的思路,需要把链表一分为二,利用快慢指针即可。 需要注意的是,写完一定要 两个节点 三个节点 代入几个 test case 检查一下,非常容易出错。下面做法是把最后slow的位置作为 root,递归左半边和右半边。 时间复杂度 O(nlogn) 空间复杂度 O( ...
分类:其他好文   时间:2018-08-26 00:03:13    阅读次数:128
PAT甲级目录
树 备注 1004 Counting Leaves 1020 Tree Traversals 1043 Is It a Binary Search Tree 判断BST,BST的性质 1053 Path of Equal Weight 1064 Complete Binary Search Tree... ...
分类:其他好文   时间:2018-08-25 19:59:20    阅读次数:147
pat甲级1123
An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any ...
分类:其他好文   时间:2018-08-25 17:36:43    阅读次数:263
Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
使用tensorflow时,提示 去掉这个提示信息方法为修改~/.bashrc文件,最后加上一句 执行 即可 ...
分类:其他好文   时间:2018-08-25 14:34:14    阅读次数:277
单个源文件下CmakeList.txt
单个源文件下CmakeList.txt 1. main.c代码 & CmakeLists.txt 文件内容 在任意自己选定的目录下(t1/)编写main.c 与 CmakeLists.txt main.c 文件内容: CMakeLists.txt 文件内容: 2. 编译与运行 现在$t1/$目录下存 ...
分类:其他好文   时间:2018-08-25 14:02:35    阅读次数:124
树的层次遍历(Trees on the level,UVA 122)
题目描述: 题目思路: 1.用结构链表来建树 2.用队列来实现层次遍历,当遍历到根节点时,将其子节点压入队列 ...
分类:其他好文   时间:2018-08-25 11:47:55    阅读次数:145
LeetCode 236. Lowest Common Ancestor of a Binary Tree; 235. Lowest Common Ancestor of a Binary Search Tree
236. Lowest Common Ancestor of a Binary Tree 递归寻找p或q,如果找到,层层向上返回,知道 root 左边和右边都不为NULL:if (left!=NULL && right!=NULL) return root; 时间复杂度 O(n),空间复杂度 O(H ...
分类:其他好文   时间:2018-08-25 11:43:20    阅读次数:122
LeetCode 110. Balanced Binary Tree
二叉树的问题,这里主要关心一下时间复杂度。 先回忆一下求二叉树深度的问题,T(n) = 2T(n/2)+1 -> O(n) 本题 T(n) = 2T(n/2) + O(n) -> O(nlogn) 最坏情况是O(n^2) 可以继续优化,一旦发现子树不是平衡的,返回-1,最后只要判断 f(root)! ...
分类:其他好文   时间:2018-08-25 11:38:17    阅读次数:103
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!