随笔分类 -  tree

上一页 1 2

[leetcode]Convert Sorted Array to Binary Search Tree
摘要:Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.算法:根据有序数组,生... 阅读全文

posted @ 2014-07-31 20:19 喵星人与汪星人 阅读(138) 评论(0) 推荐(0) 编辑

[leetcode]Construct Binary Tree from Inorder and Postorder Traversal
摘要:Construct Binary Tree from Inorder and Postorder TraversalGiven inorder and postorder traversal of a tree, construct the binary tree.Note:You may assu... 阅读全文

posted @ 2014-07-31 20:16 喵星人与汪星人 阅读(227) 评论(0) 推荐(0) 编辑

[leetcode]Construct Binary Tree from Preorder and Inorder Traversal
摘要:Construct Binary Tree from Preorder and Inorder TraversalGiven preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume... 阅读全文

posted @ 2014-07-31 20:11 喵星人与汪星人 阅读(207) 评论(0) 推荐(0) 编辑

[leetcode]Minimum Depth of Binary Tree
摘要:Minimum Depth of Binary TreeGiven a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root... 阅读全文

posted @ 2014-07-31 20:06 喵星人与汪星人 阅读(214) 评论(0) 推荐(0) 编辑

[leetcode]Maximum Depth of Binary Tree
摘要:Maximum Depth of Binary TreeGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root ... 阅读全文

posted @ 2014-07-31 20:02 喵星人与汪星人 阅读(128) 评论(0) 推荐(0) 编辑

[leetcode]Same Tree
摘要:Same TreeGiven two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally ide... 阅读全文

posted @ 2014-07-31 19:56 喵星人与汪星人 阅读(150) 评论(0) 推荐(0) 编辑

[leetcode]Symmetric Tree
摘要:Symmetric TreeGiven a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric... 阅读全文

posted @ 2014-07-31 19:53 喵星人与汪星人 阅读(163) 评论(0) 推荐(0) 编辑

[leetcode]Recover Binary Search Tree
摘要:Recover Binary Search TreeTwo elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A sol... 阅读全文

posted @ 2014-07-31 19:47 喵星人与汪星人 阅读(236) 评论(0) 推荐(0) 编辑

[leetcode]Validate Binary Search Tree
摘要:Validate Binary Search TreeGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtre... 阅读全文

posted @ 2014-07-31 19:39 喵星人与汪星人 阅读(188) 评论(0) 推荐(0) 编辑

[leetcode]Pow(x, n)
摘要:Pow(x, n)Implement pow(x,n).算法思路:二分法,没什么好说的,小心点就行;这个题时间比较苛刻。return pow(x,n >> 1) * pow(x,n >> 1) 是过不去的,因此把pow(x,n / 2)求出来先。其实时间复杂度而言,是一样的。【注意】:n的取值范围;... 阅读全文

posted @ 2014-07-25 23:31 喵星人与汪星人 阅读(172) 评论(0) 推荐(0) 编辑

上一页 1 2