Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution stil...
分类:
其他好文 时间:
2014-08-04 13:32:57
阅读次数:
184
题目:Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution ....
分类:
编程语言 时间:
2014-08-04 10:31:57
阅读次数:
239
题目:Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".题解:二进制加法都是从最低位(从右加到左)。所以对两个字符串要从最后一位开始加,....
分类:
编程语言 时间:
2014-08-04 06:13:36
阅读次数:
291
题目: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
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
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
问题:将二叉树的所有结点指向他的右边的一个结点分析:对于每一个结点来说,其操作都是一样的,除了他的左儿子指向右儿子外,其左儿子的全部右后辈均指向其右儿子的全部左后辈/** * Definition for binary tree with next pointer. * struct TreeLin...
分类:
其他好文 时间:
2014-08-03 10:12:05
阅读次数:
178