NOTE: 1.将大多数inline限制在小型 被频繁调用的函数身上。这可使日后的调试过程和二进制升级(binary upgradability)更容易,也可使潜在的代码膨胀问题最小化,使程序的速度提升机会最大化。 2.不要只因为 function templates 出现在头文件,就将...
分类:
其他好文 时间:
2015-09-17 00:52:34
阅读次数:
170
二叉树的遍历(traversing binary tree)是指从根节点出发,按照某种次序依次访问二叉树中所有节点,使得每个节点仅被访问一次前序遍历:若二叉树为空,则空操作返回null。否则先访问根节点,然后前序遍历左子树,再前序遍历右子树中序遍历:若二叉树为空,则空操作返回null。否则从根节点开...
分类:
编程语言 时间:
2015-09-16 23:28:25
阅读次数:
314
Binary Search Tree IteratorImplement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callin...
分类:
其他好文 时间:
2015-09-16 23:20:13
阅读次数:
171
Sum Root to Leaf NumbersGiven a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-l...
分类:
其他好文 时间:
2015-09-16 17:39:34
阅读次数:
106
题目:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next poi...
分类:
其他好文 时间:
2015-09-16 12:40:10
阅读次数:
160
Kth Smallest Element in a BSTGiven a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is alw...
分类:
其他好文 时间:
2015-09-16 12:30:01
阅读次数:
143
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth...
分类:
其他好文 时间:
2015-09-16 06:19:09
阅读次数:
140
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ ...
分类:
其他好文 时间:
2015-09-16 06:18:37
阅读次数:
133
voidsolve(intALeft,intARight,intTRoot){/*为初始调用为solve(0,N-1,0)*/n=ARight–ALeft+1;if(n==0)return;L=GetLeftLength(n);/*计算出n点个结点的树其左子树有多少个结点*/T[TRoot]=A[ALeft+L];LeftTRoot=TRoot*2+1;RightTRoot=LeftTRoot+1;solve(ALeft,ALeft+L-1,LeftTRo..
分类:
其他好文 时间:
2015-09-16 01:07:56
阅读次数:
155
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ...
分类:
其他好文 时间:
2015-09-15 21:55:34
阅读次数:
160