题目:Binary Tree Preorder Traversal二叉树的前序遍历,同样使用栈来解,代码如下: 1 struct TreeNode { 2 int val; 3 TreeNode* left; 4 TreeNode* righ...
分类:
其他好文 时间:
2014-10-11 22:44:56
阅读次数:
222
题目:Binary Tree Inorder Traversal二叉树的中序遍历,和前序、中序一样的处理方式,代码见下: 1 struct TreeNode { 2 int val; 3 TreeNode* left; 4 TreeNode* ...
分类:
其他好文 时间:
2014-10-11 22:03:26
阅读次数:
233
表设计如图:id title parentid1 asp.net 02 c# 03 c#_0 24 c#_1 35 c#_2 4页面中添加一个TreeView控件写添加节点方法: private void AddNode(int id, TreeNode parentnode) { string ....
分类:
Web程序 时间:
2014-10-09 22:45:47
阅读次数:
221
类图
/**
* 树 整体
*
* @author stone
*
*/
public class Tree {
private TreeNode root; //根节点
public Tree(String name) {
this.root = new TreeNode(name);
}
public TreeNode getRoot() {
re...
分类:
编程语言 时间:
2014-10-09 21:08:25
阅读次数:
213
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
/**
* http...
分类:
其他好文 时间:
2014-10-08 01:05:04
阅读次数:
253
struct TreeNode{ int val; TreeNode* left; TreeNode* right; TreeNode(int val):val(val),left(NULL),right(NULL){}};Not all binary trees are bina...
分类:
其他好文 时间:
2014-10-07 15:02:23
阅读次数:
221
Given preorder and inorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
/**
* Definition for binary tree
* struct TreeNode {
...
分类:
其他好文 时间:
2014-10-06 14:46:30
阅读次数:
202
Given inorder and postorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
/**
* Definition for binary tree
* struct TreeNode {...
分类:
其他好文 时间:
2014-10-06 14:45:50
阅读次数:
178
非递归解法
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class...
分类:
其他好文 时间:
2014-10-06 12:54:00
阅读次数:
211
题目链接:http://poj.org/problem?id=1002思路: 先对输入字符进行处理,转换为标准形式;插入标准形式的电话号码到查找树中,若有相同号码计数器增加1,再中序遍历查找树。代码:#include #include #include struct TreeNode;typede....
分类:
其他好文 时间:
2014-10-06 06:19:29
阅读次数:
202