题目地址:HDU 1710
已知二叉树先序和中序求后序。
#include
#include
int a[1001], cnt;
typedef struct node
{
int date ;
node *lchild , *rchild ;
}*tree;
int getk(int ch,int ino[],int is,int n)
{
for(int i =...
分类:
其他好文 时间:
2014-07-31 13:25:46
阅读次数:
225
红黑树数据结构#ifndef __RED_BLACK_TREE_H#define __RED_BLACK_TREE_H#define RED 1#define BLACK 0typedef struct Red_Black_Node{ int id; int color; int ...
分类:
其他好文 时间:
2014-07-31 12:49:56
阅读次数:
165
二叉树的前序遍历递归实现/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : v...
分类:
其他好文 时间:
2014-07-31 12:44:46
阅读次数:
188
二叉树的后序遍历递归实现/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : v...
分类:
其他好文 时间:
2014-07-31 12:30:16
阅读次数:
224
第一题线段树,纪念一下 1 #include 2 #include 3 using namespace std; 4 int tree[800005]; 5 void build(int l,int r,int root){ 6 if(l==r){ 7 scanf("%...
分类:
其他好文 时间:
2014-07-31 12:23:06
阅读次数:
208
题目链接:http://poj.org/problem?id=3264题目大意:在给定一堆牛的数量以及其高度的时候,每次给定一段区间,求这个区间内最高的牛和最矮的牛的高度之差为多少。这道题目用线段树能快速的求解,因为此处不涉及更新,所以无需写update函数不同于之前只定义一个tree数组,这回我们...
分类:
其他好文 时间:
2014-07-31 09:47:16
阅读次数:
210
题目:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and ....
分类:
编程语言 时间:
2014-07-31 05:22:15
阅读次数:
287
题目:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.题解:先复习下什么是二叉搜索树(引自Wikipedia):二叉查找树(Binary Search ....
分类:
编程语言 时间:
2014-07-31 05:21:55
阅读次数:
215
题目: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 d....
分类:
编程语言 时间:
2014-07-31 05:21:35
阅读次数:
221
题目:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given su....
分类:
编程语言 时间:
2014-07-31 05:21:25
阅读次数:
214