二叉树的各种遍历方法有 前序遍历 中序遍历 后序遍历 层序遍历。其中前三种遍历有递归程序可以实现,但是我们也有必要掌握其非递归版本的算法实现。正好在leetcode中遇到了遍历二叉树的问题,今天在这里一并总结了。首先,引用leetcode中关于二叉树节点的定义。1 // Definition ...
分类:
编程语言 时间:
2014-11-09 12:37:56
阅读次数:
329
Given inorder and postorder traversal of a tree, construct the binary tree.Solution: 1 /** 2 * Definition for binary tree 3 * public class TreeNode .....
分类:
其他好文 时间:
2014-11-09 06:16:44
阅读次数:
215
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.Solution: 1 /** 2 * Definition for binary tree 3 * .....
分类:
其他好文 时间:
2014-11-09 00:58:31
阅读次数:
213
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.Solution: 1 /** 2 * Definition for singl....
分类:
其他好文 时间:
2014-11-09 00:52:30
阅读次数:
316
Brackets
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 3340
Accepted: 1716
Description
We give the following inductive definition of a “regular bracket...
分类:
其他好文 时间:
2014-11-08 23:41:30
阅读次数:
280
1. 访问机制 CSMA/CA: Carrier Sense Multiple Access with Collision Avoidance WiFi采用带冲突避免的载波监听多路访问机制来控制对传输媒介的访问 不同于以太网,WiFi没有明确的冲突碰撞检测机制 WiFi MAC层指定了如下规则来检测...
分类:
系统相关 时间:
2014-11-08 23:25:27
阅读次数:
1407
1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(i...
分类:
其他好文 时间:
2014-11-08 21:58:27
阅读次数:
179
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1019解题思路:lcm(a,b)=a*b/gcd(a,b)反思:最开始提交的时候WA,以为是溢出了,于是改成了long long,还是WA,于是就不明白了,于是就去看了discuss,发现应该这样来写 l...
分类:
其他好文 时间:
2014-11-08 18:14:46
阅读次数:
187
A suffix array is a sorted array of all suffixes of a given string. The definition is similar to Suffix Tree which is compressed trie of all suffixes ...
分类:
其他好文 时间:
2014-11-08 13:38:45
阅读次数:
193
Abstract. BRep short for Boundary Representation. First give the definition of the BRep, then compare the BRep mode between OpenCASCADE and OpenNURBS....
分类:
其他好文 时间:
2014-11-08 13:21:09
阅读次数:
531