码迷,mamicode.com
首页 >  
搜索关键字:binary trees    ( 12390个结果)
hdu 5375 Gray code(DP)
hdu 5375 Gray codeProblem Description The reflected binary code, also known as Gray code after Frank Gray, is a binary numeral system where two successive values differ in only onebit (binary digit)....
分类:其他好文   时间:2015-08-11 23:35:32    阅读次数:171
leetcode: Binary Tree Preorder Traversal
Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 2 / 3 return [1,2,3]. Note: Recursive soluti...
分类:其他好文   时间:2015-08-11 23:34:22    阅读次数:131
leetcode——Lowest Common Ancestor of a Binary Search Tree
题目Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.思路题目要求一个二叉排序树的两个节点的公共父节点,说通俗点,其实就是这两个节点所在的分支是从哪里开始分叉的。求出这个分叉点。对于二叉排序树,它的一个特点就是:一个节点的左子树节点都小于该节点,而...
分类:其他好文   时间:2015-08-11 21:34:48    阅读次数:137
leetcode——Lowest Common Ancestor of a Binary Tree
题目Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.思路这一次说的是一个普通的二叉树,给出两个节点,求他们的最低公共父节点。 回想一下,当这棵二叉树是二分查找树的时候的解决方案: 二分查找树解法:http://blog.csdn.net/langduhualangd...
分类:其他好文   时间:2015-08-11 21:26:38    阅读次数:114
[LeetCode] Construct Binary Tree from Preorder and Inorder Traversal
Construct Binary Tree from Preorder and Inorder Traversal Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tre...
分类:其他好文   时间:2015-08-11 18:58:28    阅读次数:145
[LeetCode] Convert Sorted Array to Binary Search Tree
Convert Sorted Array to Binary Search Tree Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 解题思路: 题意为构建有序数组的二分查找树。比较简单,用递归方法即可,中间的元素作为根节点,前半部分作为左孩...
分类:其他好文   时间:2015-08-11 18:58:16    阅读次数:214
[LeetCode] Convert Sorted List to Binary Search Tree
Convert Sorted List to Binary Search Tree Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 解题思路: 题意为构造有序链表的二分查找树。找到中间节点的办法用双指针法。注意我们...
分类:其他好文   时间:2015-08-11 18:51:47    阅读次数:136
hdoj-1131-Count the Trees
Count the Trees Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1798 Accepted Submission(s): 1195 Problem Description Another common soci...
分类:其他好文   时间:2015-08-11 18:44:28    阅读次数:120
[LeetCode] Flatten Binary Tree to Linked List
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 6 The fl...
分类:其他好文   时间:2015-08-11 18:44:03    阅读次数:110
hdoj-1130-How Many Trees?【卡特兰数】
How Many Trees? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3224 Accepted Submission(s): 1870 Problem Description A binary search tree...
分类:其他好文   时间:2015-08-11 18:42:35    阅读次数:117
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!