码迷,mamicode.com
首页 >  
搜索关键字:hdoj tree    ( 20544个结果
第十章 基本数据结构 练习 10.4-4
package chap10;import static org.junit.Assert.*;import java.util.Stack;import org.junit.Test;public class exec10_4_4 { /** * 将该树打印 * * @param tree */ ...
分类:其他好文   时间:2014-06-16 10:58:06    阅读次数:183
【HDOJ】1892 See you~
wa了十次,原来变量名写错。二维树状数组。 1 #include 2 #include 3 4 #define MAXN 1002 5 6 int nums[MAXN][MAXN]; 7 8 void swap(int *x, int *y) { 9 int tmp;10 ...
分类:其他好文   时间:2014-06-16 08:34:51    阅读次数:216
HDOJ 1196 Lowest Bit
题目大意是给一个1-100的整数,要求首先转化成2进制,然后从最低位开始数起到不是0的位停止,输出这些位代表队额10进制数 1 #include 2 3 using namespace std; 4 5 int bits[7]={1,2,4,8,16,32,64}; 6 int judge(i...
分类:其他好文   时间:2014-06-16 08:10:21    阅读次数:226
树状数组
一、树状数组树状数组是一个优美小巧的数据结构,在很多时候可以代替线段树。一句话概括就是,凡是树状数组可以解决的问题,线段树都可以解决,反过来线段树可以解决的问题,树状数组不一定能解决。树状数组英文名称为Binary Index Tree,直译过来就是二进制索引树,我觉得二进制索引树更能说明其本质。树...
分类:其他好文   时间:2014-06-16 07:24:03    阅读次数:190
Leetcode | Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.递归,二分法。 1 /** 2 * Definition for binary tree 3 * st.....
分类:其他好文   时间:2014-06-16 00:33:31    阅读次数:252
BZOJ1588 营业额统计 splay tree
最基本的平衡树操作吧,第一次学splay的可以做一下只需要插入,删除,旋转,求前驱,后继这5个操作吧不喜欢用指针,用数组写的//HNOI2002营业额统计 #include#include#include#include#define INF 1key[root]],root,k); Spla...
分类:其他好文   时间:2014-06-13 20:10:15    阅读次数:282
线段树 Interval Tree
一、线段树线段树既是线段也是树,并且是一棵二叉树,每个结点是一条线段,每条线段的左右儿子线段分别是该线段的左半和右半区间,递归定义之后就是一棵线段树。例题:给定N条线段,{[2, 5], [4, 6], [0, 7]}, M个点{2, 4, 7},判断每个点分别在几条线段出现过?1、构建线段树2、处...
分类:其他好文   时间:2014-06-13 18:43:01    阅读次数:262
Leetcode:Path Sum 二叉树路径和
Path Sum: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 giv...
分类:其他好文   时间:2014-06-13 16:09:02    阅读次数:237
leetcode--Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t...
分类:其他好文   时间:2014-06-13 15:11:35    阅读次数:273
【HDOJ】1930 And Now, a Remainder from Our Sponsor
简单字符串。 1 #include 2 3 #define MAXLEN 160 4 5 char buf[MAXLEN]; 6 int keys[4], parts[4]; 7 8 void getpart(int x) { 9 int i;10 for (i=3; i>=...
分类:其他好文   时间:2014-06-13 15:10:31    阅读次数:242
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!