二叉查找树(Binary Search Tree),也称二叉排序树(binary sorted tree),是指一棵空树或者具有下列性质的二叉树:若任意节点的左子树不空,则左子树上所有结点的值均小于它的根结点的值任意节点的右子树不空,则右子树上所有结点的值均大于它的根结点的值任意节点的左、右子树也分...
分类:
其他好文 时间:
2014-06-16 23:32:04
阅读次数:
199
1.PyDictObject对象 --> C++ STL中的map是基于RB-tree的,搜索时间复杂度是O(logN)
PyDictObject采用了hash表,时间复杂度是O(1)
typedef struct{
Py_ssize_t me_hash; //me_key的hash值,避免每次查询都要重新计算一遍hash值
PyObject *me_key;
PyObject *me_value;
}PyDictEntry;
将(key,value)对称为entry,它可以在3种状态...
分类:
编程语言 时间:
2014-06-16 21:22:45
阅读次数:
272
demo代码如下。欢迎指正与讨论。#include<iostream>
#include<queue>
#include<stack>
usingnamespacestd;
template<typenameT>
structBinaryNode{
Telem;
BinaryNode*left;
BinaryNode*right;
BinaryNode(Td,BinaryNode*l=NULL,BinaryNode*r=NUL..
分类:
其他好文 时间:
2014-06-16 16:35:05
阅读次数:
278
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).
For example:
Given binary tree {3,9,20,#,#,15,7},
...
分类:
其他好文 时间:
2014-06-15 15:17:43
阅读次数:
192
Given a binary tree containing digits from
0-9 only, each root-to-leaf path
could represent a number.
An example is the root-to-leaf path
1->2->3 which represents the number 123.
F...
分类:
其他好文 时间:
2014-06-15 14:51:02
阅读次数:
167
初始化异步树直接全部展开代码:
$(function(){
$('#tt').tree({
url:'/treeInit',
lines:true,
onLoadSuccess:function(node,data){
var t = $(this);
if(data){
$(data).each(f...
分类:
其他好文 时间:
2014-06-15 13:30:02
阅读次数:
242
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).
For example:
Given binary tree {3,9,20,#,#,15,7},
3
/ 9 20
...
分类:
其他好文 时间:
2014-06-15 13:26:54
阅读次数:
200
题目:Unique Binary Search TreesGivenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a...
分类:
其他好文 时间:
2014-06-15 13:16:53
阅读次数:
202
二叉树(Binary Tree)是个有限元素的集合,该集合或者为空、或者由一个称为根(root)的元素及两个不相交的、被分别称为左子树和右子树的二叉树组成。当集合为空时,称该二叉树为空二叉树。在二叉树中,一个元素也称作一个结点。基本概念:(1)结点的度。结点所拥有的子树的个数称为该结点的度。(2)叶...
分类:
其他好文 时间:
2014-06-15 11:14:30
阅读次数:
255
1、
??
Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return ...
分类:
其他好文 时间:
2014-06-14 14:11:27
阅读次数:
315