Convert Sorted List to Binary Search TreeGiven a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST....
                            
                            
                                分类:
其他好文   时间:
2014-12-28 12:50:15   
                                阅读次数:
170
                             
                    
                        
                            
                            
                                【题目】
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
【分析】
二分法,以中间元素i为根节点[start,i-1]递归构建左子树,[i+1,end]递归构建右子树
【代码】
/*****************************...
                            
                            
                                分类:
其他好文   时间:
2014-12-28 11:41:50   
                                阅读次数:
240
                             
                    
                        
                            
                            
                                Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.题意:给一个升序排好的...
                            
                            
                                分类:
其他好文   时间:
2014-12-27 20:23:04   
                                阅读次数:
235
                             
                    
                        
                            
                            
                                Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
这个问题比较简单,用递归是个不错的选择,我的C++代码实现如下:
class Solution {
public:
    TreeNode *sortedArrayToBST(vecto...
                            
                            
                                分类:
其他好文   时间:
2014-12-25 22:09:34   
                                阅读次数:
241
                             
                    
                        
                            
                            
                                【题目】
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 of the two subtrees of every node n...
                            
                            
                                分类:
其他好文   时间:
2014-12-24 16:23:25   
                                阅读次数:
200
                             
                    
                        
                            
                            
                                Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.SOLUTION 1:...
                            
                            
                                分类:
其他好文   时间:
2014-12-23 13:52:56   
                                阅读次数:
200
                             
                    
                        
                            
                            
                                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 tr...
                            
                            
                                分类:
其他好文   时间:
2014-12-18 22:05:21   
                                阅读次数:
180
                             
                    
                        
                            
                            
                                题目
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 of the two subtrees of every node nev...
                            
                            
                                分类:
其他好文   时间:
2014-12-18 15:16:38   
                                阅读次数:
169
                             
                    
                        
                            
                            
                                标题:Balanced Binary Tree通过率:32.3%难度:简单Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is define...
                            
                            
                                分类:
其他好文   时间:
2014-12-18 14:50:55   
                                阅读次数:
186
                             
                    
                        
                            
                            
                                1637: [Usaco2007 Mar]Balanced LineupTime Limit:5 SecMemory Limit:64 MBSubmit:393Solved:263[Submit][Status]DescriptionFarmer John 决定给他的奶牛们照一张合影,他让 N (1...
                            
                            
                                分类:
其他好文   时间:
2014-12-17 00:08:16   
                                阅读次数:
194