码迷,mamicode.com
首页 >  
搜索关键字:binary trees    ( 12390个结果)
538. Convert BST to Greater Tree 二叉搜索树转换为更大树
Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all ... ...
分类:其他好文   时间:2017-07-09 23:58:24    阅读次数:466
Codeforces Round #245 (Div. 1)A. Xor-tree(深搜)
传送门 Description Iahub is very proud of his recent discovery, propagating trees. Right now, he invented a new tree, called xor-tree. After this new rev ...
分类:其他好文   时间:2017-07-09 23:56:18    阅读次数:243
2-3 树
转自:http://www.cnblogs.com/yangecnu/p/Introduce-2-3-Search-Tree.html 前面介绍了二叉查找树(Binary Search Tree),他对于大多数情况下的查找和插入在效率上来说是没有问题的,但是他在最差的情况下效率比较低。本文及后面文章 ...
分类:其他好文   时间:2017-07-09 22:07:52    阅读次数:273
637. Average of Levels in Binary Tree 二叉树每一层的平均值
Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array.Example 1:Input: 3 / \ 9 20 / \ 15 7 Output... ...
分类:其他好文   时间:2017-07-09 19:46:58    阅读次数:137
236. Lowest Common Ancestor of a Binary Tree
https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/#/description Given a binary tree, find the lowest common ancestor (LCA) of two ...
分类:其他好文   时间:2017-07-09 16:18:14    阅读次数:179
leetcode: invert binary tree
1. 问题描述: 旋转一颗二叉树(每一个节点的左右子数都要交换) 2. 解答: 这题没看答案之前我是用后序遍历(先左后右最后中)去做的,很奇怪自己为什么没有一开始就想到更符合直觉的先序遍历~~~ 本人算法的伪代码 : function invert (root) if root为空 then end ...
分类:其他好文   时间:2017-07-09 14:50:20    阅读次数:212
[leetcode-637-Average of Levels in Binary Tree]
Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: 思路: 层次遍历。 ...
分类:其他好文   时间:2017-07-09 13:57:22    阅读次数:195
Binary Tree Maximum Path Sum 自底向上求解(重重重重)
题目: 链接 解答: 自底向上求解。left_max right_max分别返回了左右子树的最大路径和,假设左右子树最大路径和小于0。那么返回零。 用这个最大路径和和根节点的值相加。来更新最大值,同一时候。 更新返回该树的最大路径值。 代码: class Solution { public: int ...
分类:其他好文   时间:2017-07-09 12:28:09    阅读次数:129
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. /** * Definition for binary tree * struct TreeNode { ...
分类:其他好文   时间:2017-07-09 10:26:57    阅读次数:153
[LeetCode] Merge Two Binary Trees
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are n ...
分类:其他好文   时间:2017-07-08 21:06:52    阅读次数:119
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!