题目:The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total ....
分类:
编程语言 时间:
2014-08-04 04:10:46
阅读次数:
309
很自然想起来递归:
代码:
#include
#include
using namespace std;
typedef struct tree1{
int data;
struct tree1 * lchild;
struct tree1 * rchild;
}Tree,* pTree;
void createTree(pTree & p){
int temp ;
scan...
分类:
其他好文 时间:
2014-08-03 23:23:58
阅读次数:
267
题意:给你一棵树,问你树中距离为k的有多少种情况。解题思路:树形dp 维护每个节点(1-K)深度的情况,解题代码: 1 // File Name: 161d.cpp 2 // Author: darkdream 3 // Created Time: 2014年08月03日 星期日 19时20分10秒...
分类:
其他好文 时间:
2014-08-03 20:36:35
阅读次数:
201
package com.iflytek.tree;
import java.util.Random;
/**
* 二叉查找树
* @author fgtian
*
*/
public class BinaryTree {
public static class BinaryTreeNode {
int mValue; // 数值:以int代替,可以扩展成其他的
Binary...
分类:
其他好文 时间:
2014-08-03 18:09:35
阅读次数:
211
在stl中容器分为两大类,序列式容器和关联式容器。序列式容器:array、vector、heap、priority-queue、list、slist、deque、(stack、queue)最后两个是配接器关联式容器:RB-tree、set、map、multiset、multimap、hashtabl...
分类:
其他好文 时间:
2014-08-03 17:50:15
阅读次数:
232
题目: 给定一个二叉树(假设是完全二叉树),把每个节点的next指针指向其右侧节点。
思路:首先想到的是,层序遍历树,在遍历的同时添加节点对右侧节点的指针。
另一种简洁的方法是采用递归来实现,间单直观。...
分类:
其他好文 时间:
2014-08-03 15:23:45
阅读次数:
246
JsRender DemosExample Scenario: Accessing parent data.Stepping up through the views (tree of nested rendered templates) TitleLang...
分类:
Web程序 时间:
2014-08-03 15:10:25
阅读次数:
294
Given two binary trees, write a function to check if they are equal or not.
Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
/**
...
分类:
其他好文 时间:
2014-08-03 12:54:55
阅读次数:
201
Consider an infinite full binary search tree (see the figure below), the numbers in the nodes are 1, 2, 3, .... In a subtree whose root node is X, we can get the minimum number in this subtree by repe...
分类:
其他好文 时间:
2014-08-03 12:49:15
阅读次数:
229
二叉堆(binary heap) 二叉堆数据结构是一种数组对象,它可以被视为一棵完全二叉树。同二叉查找树一样,堆也有两个性质,即结构性和堆序性。对于数组中任意位置i上的元素,其左儿子在位置2i上,右儿子在左儿子后的单元2i+1中,它的父亲在[i/2](向下取整)中。因此,一个数据结构将由一个数组、....
分类:
其他好文 时间:
2014-08-03 12:30:25
阅读次数:
324