我们知道二叉搜索树的中序遍历是一个已经排好序的序列,知道序列我们无法确定树的形态(因为有多种)。但是,Treap如果告诉我们它的关键字以及权值,那么就可以唯一确定树的形态(Treap的O(logn)的期望时间复杂度就是依靠一个随机堆的深度不会太深)具体的,已知关键字序列:k1,k2,k3...kn和...
分类:
其他好文 时间:
2015-03-05 19:15:21
阅读次数:
171
用JSON或者XML等,不存在此问题,或者说相对容易解决此问题。 以下是指特定用Soap来进行序列化和反序列化中碰到的。 在一个程序集中: class Program{ static void Main(string[] args) { //Serialize(); A a = new A(); s...
分类:
其他好文 时间:
2015-03-05 18:56:35
阅读次数:
126
String1. char charAt(int index) :取字符串中的某一个字符,其中的参数index指的是字符串中序数。字符串的序数从0开始到length()-1 。2. int compareTo(String anotherString) :当前String对象与anotherStri...
分类:
编程语言 时间:
2015-03-01 10:22:05
阅读次数:
144
We essentailly do an in-order traversal (中序遍历) of the tree since the in-order traversal results in a sorted list of node items.1 def traverse_binary_t...
分类:
其他好文 时间:
2015-02-26 06:28:30
阅读次数:
155
class Node{public: int data; Node* left; Node* right;};void pre-order(Node* root){ stack stk; if (root) stk.push(root); while...
分类:
其他好文 时间:
2015-02-24 16:16:46
阅读次数:
122
重建二叉树
时间限制:1000 ms | 内存限制:65535 KB
难度:3
描述题目很简单,给你一棵二叉树的后序和中序序列,求出它的前序序列(So easy!)。
输入输入有多组数据(少于100组),以文件结尾结束。
每组数据仅一行,包括两个字符串,中间用空格隔开,分别表示二叉树的后序和中序序列(字符串长度小于26,输入数据保证合法)。
输出每组输出...
分类:
其他好文 时间:
2015-02-22 14:38:22
阅读次数:
131
Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note...
分类:
其他好文 时间:
2015-02-22 06:46:02
阅读次数:
162
Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.这道题要求用先序和中序遍历来建...
分类:
其他好文 时间:
2015-02-20 14:08:33
阅读次数:
169
Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.这道题要求从中序和后序遍历的...
分类:
其他好文 时间:
2015-02-19 18:37:40
阅读次数:
221
由先序遍历和中序遍历序列可唯一还原出二叉树,前提条件是所有节点的关键字无重复。题目来源:http://hihocoder.com/problemset/problem/1049代码: 1 #include 2 #include 3 4 using namespace std; 5 6 voi...
分类:
其他好文 时间:
2015-02-18 11:50:18
阅读次数:
162