码迷,mamicode.com
首页 >  
搜索关键字:binary    ( 11734个结果)
LeetCode--Recover Binary Search Tree
Recover Binary Search Tree这道题要修正二叉查找树错误节点,不改变结构。 并且时间复杂度药O(n),空间复杂度药O(1).思路:Here’s an example: 1 / 2 3 / 4 5 The above binary tree is serialized as “{1,2,3,#,#,4,#,#,5}”....
分类:其他好文   时间:2015-07-29 14:14:33    阅读次数:148
[CareerCup] 4.1 Balanced Binary Tree 平衡二叉树
4.1 Implement a function to check if a binary tree is balanced. For the purposes of this question, a balanced tree is defined to be a tree such that t...
分类:其他好文   时间:2015-07-29 13:46:49    阅读次数:99
[Leetcode]Kth Smallest Element in a BST
//用search计算左子树的节点个数,加上根节点本身若为k则输出,否则 //(1)若k大于目前个数,则k-左子树节点个数,再计算右子树 //(2)若k小于目前个数,则直接计算左子树 /**  * Definition for a binary tree node.  * struct TreeNode {  *     int val;  *     TreeNode *left;...
分类:其他好文   时间:2015-07-29 06:28:26    阅读次数:117
leetCode(52):Add Binary
Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". 题目并不复杂,以下是我的程序,后面是别人的程序,瞬间low了好大一截! 冗长!!!!!!!class Solution { public: s...
分类:其他好文   时间:2015-07-29 01:08:13    阅读次数:133
Method for balancing binary search trees
Method for balancing abinarysearchtree. A computer implemented method for balancing abinarysearchtree includes locating a node in abinarysearchtree, d...
分类:其他好文   时间:2015-07-29 00:29:23    阅读次数:199
C++实现二叉树相关操作
测试环境:windows 7 vs2010 主要实现二叉树的初始化递归和非递归遍历,层次遍历,获取叶子节点的个数,获取树的高度以及镜像树,部分代码也参考了互联网上的相关资料。 源程序: BinaryTreeNode.h #ifndef _BINARY_NODE #define _BINARY_NODE #include using namespace std; template st...
分类:编程语言   时间:2015-07-28 21:11:12    阅读次数:130
Populating Next Right Pointers in Each Node
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe...
分类:其他好文   时间:2015-07-28 20:37:01    阅读次数:69
Populating Next Right Pointers in Each Node II
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...
分类:其他好文   时间:2015-07-28 20:36:43    阅读次数:108
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...
分类:其他好文   时间:2015-07-28 18:27:00    阅读次数:82
Balanced Binary Tree
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 depth...
分类:其他好文   时间:2015-07-28 18:11:32    阅读次数:111
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!