Problem Description:
Given a binary tree, determine if it is a valid binary search tree (BST).
Assume a BST is defined as follows:
The left subtree of a node contains only nodes with keys l...
分类:
其他好文 时间:
2014-05-15 11:22:21
阅读次数:
317
题意:给定一棵perfect binary tree,将它每一个节点的next指针都指向该节点右边的节点
思路:dfs
在connect一棵树的时候,需要知道这棵树的根节点和它右边的节点
1.将树的根节点和它右边的节点连接起来
2.递归地将左子树connect起来,需要知道左子树节点和右子树节点
3.递归地将右子树connect起来,需要知道右子树节点和根右边的节点的左子树节点
递归函数为:
void connect(TreeLinkNode *root, TreeLinkNode *sibling)
表...
分类:
其他好文 时间:
2014-05-15 07:14:04
阅读次数:
289
题意:给定一棵任意二叉树(不一定是perfect binary tree),将它每一个节点的next指针都指向该节点右边的节点
思路:bfs
这里不能用dfs了,只能用bfs
bfs遍历将同一层的节点存放在同一个数组里,
然后在遍历每个数组,将前面的节点和后面的节点connect起来,
最后一个节点和NULL connect起来
需要定义一个新的struct结构,保存指向每个节点的指针和该节点所在的层
复杂度:时间O(n), 空间O( n)...
分类:
其他好文 时间:
2014-05-15 06:12:13
阅读次数:
294
1、
??
Populating Next Right Pointers in Each Node
Given a binary tree
struct TreeLinkNode {
TreeLinkNode *left;
TreeLinkNode *right;
TreeLinkNode *next;
}
Populate...
分类:
其他好文 时间:
2014-05-15 04:57:36
阅读次数:
221
第一次使用ModelAdmin.date_query,在admin.py中添加后,出现了这样的错误
ImproperlyConfigured exception (pytz isn't installed)
使用以下命令安装pytz之后,问题依然没有解决
$sudo pip install pytz
根据搜索结果,原来需要把settings.p中的USE_TZ = True修改为USE_T...
分类:
其他好文 时间:
2014-05-15 03:42:23
阅读次数:
224
题目来源:UVa 10308 Roads in the North
题意:求距离最远的2点之间的距离
思路:裸的树的直径 或者树形DP
#include
#include
#include
using namespace std;
const int maxn = 100010;
struct node
{
int to, w;
node(){}
node(int to, int...
分类:
其他好文 时间:
2014-05-15 03:37:18
阅读次数:
295
在虚拟机上安装 Kali 的时候什么问题都没有,在实体机上安装就出现问题了。
首先选择的是 Install,就是文字安装,安装的时候经过选择国家语言,到探测网络硬件,屏幕上显示“探测网络硬件”,然后就一直卡在那。然后又用了 Graphical Install,结果还是一样,等了半个小时还是卡着不动。
在网上找了有方法可以跳过探测网络硬件的,但是我试过了发现还是不行,因为他跳过探测网络硬件的话,...
分类:
系统相关 时间:
2014-05-15 03:16:30
阅读次数:
489
Sometimesthemavenbuildingjustneedsoneormore3rdpartyjars,andthejarscannotbedownloadedandinstalledautomaticallybyInternet.Thenyoucaninstallthesejarsmanually.1st.Installa3rdpartyjarpackageintomavenrepositormvninstall:install-file-DgroupId=<jar‘sgroupdId>..
分类:
其他好文 时间:
2014-05-14 17:23:24
阅读次数:
343
node.js API 英文原版
http://nodejs.org/api/all.html
node.js API 中文翻译
http://nodeapi.ucdok.com/#/api/
node.js API 中文翻译下载
http://download.csdn.net/detail/bad19876414641/4608699
javascrip...
分类:
Web程序 时间:
2014-05-14 15:15:10
阅读次数:
329
mysql5.6.14配置my.cnf多实例,mysql_install_db初始化不读取my.cnf配置文件
[ERROR] InnoDB: auto-extending data file ./ibdata1 is of a differentsize 768 pages (rounded down to MB) than specified in the .cnf file: initial65536 pages, max 0 (relevant if non-zero) pages!
2014-0...
分类:
数据库 时间:
2014-05-14 14:20:48
阅读次数:
412