码迷,mamicode.com
首页 >  
搜索关键字:binary tree upside d    ( 23249个结果)
2489 Minimal Ratio Tree
原题:http://acm.hdu.edu.cn/showproblem.php?pid=2489【类型】最小生成树+DFS【题意】给出一张n个点的图,图中的每一个结点以及每一条边都有其权值,要求从中选出m个点,找到m-1条边将其连接,使得边权值与点权值的比值达到最小。【分析】要使得比值最小,则点权...
分类:其他好文   时间:2014-09-06 21:08:23    阅读次数:288
BZOJ 1500 NOI 2005 维修数列 Splay
题意:见下图 传说级别的NOI数据结构神题,像我这种弱渣花了一下午的时间才A掉,最后发现竟然是边界值的问题没处理好。。 这个题对Splay的所有操作基本是全了。 插入:新建一颗Splay Tree,然后把对应节点Splay到根的右儿子上,再把新建的树连上。 删除:把要删除的区间Splay到根的右儿子的左儿子上,递归free掉。(这里可以用数组优化,可以避免递归free节...
分类:其他好文   时间:2014-09-06 09:48:03    阅读次数:242
[LeetCode] Binary Tree Preorder Traversal
public class Solution { public List preorderTraversal(TreeNode root) { List result = new ArrayList(); Stack nodeStack = new Stack();...
分类:其他好文   时间:2014-09-05 22:17:42    阅读次数:246
Flatten Binary Tree to Linked List
Problem Description: Given a binary tree, flatten it to a linked list in-place. For example, Given 1 / 2 5 / \ 3 4 6 The flattened tree s...
分类:其他好文   时间:2014-09-05 19:57:31    阅读次数:205
Leetcode bfs&dfs Binary Tree Postorder Traversal II
Binary Tree Level Order Traversal II  Total Accepted: 16983 Total Submissions: 54229My Submissions Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie...
分类:其他好文   时间:2014-09-05 18:22:41    阅读次数:212
Leetcode bfs&dfs Binary Tree Postorder Traversal
Binary Tree Level Order Traversal  Total Accepted: 20571 Total Submissions: 66679My Submissions Given a binary tree, return the level order traversal of its nodes' values. (ie, from left t...
分类:其他好文   时间:2014-09-05 18:22:21    阅读次数:271
Leetcode--Convert Sorted List to Binary Search Tree
Problem Description: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 分析:很容易想到的一种解法是将链表中所有的元素保存到数组中,然后每次取中间值进行构造,时间复杂度为O(n),空间复杂度为O(n)。具体...
分类:其他好文   时间:2014-09-05 18:14:11    阅读次数:223
mysql之slave_skip_errors选项
要说slave_skip_errors选项,就不得不提mysql的replication机制,总的来说它分了三步来实现mysql主从库的同步master将改变记录到二进制日志(binary log)中(这些记录叫做二进制日志事件,binary log events);slave将master的bin...
分类:数据库   时间:2014-09-05 18:03:51    阅读次数:380
二叉树的先序、中序、后序、层次遍历的递归和非递归解法
二叉树的先序、中序、后序、层次遍历的递归和非递归解法 package tree; import java.util.LinkedList; import java.util.Queue; import java.util.Stack; public class TreeTraverse { /** * 先序递归 * @param root */ public stat...
分类:其他好文   时间:2014-09-05 16:12:21    阅读次数:249
Leetcode dfs Sum Root to Leaf Numbers
Sum Root to Leaf Numbers  Total Accepted: 20237 Total Submissions: 67979My Submissions Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a numbe...
分类:其他好文   时间:2014-09-05 16:12:01    阅读次数:200
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!