码迷,mamicode.com
首页 >  
搜索关键字:binary trees    ( 12390个结果)
二叉搜索树的后序遍历序列
给定一个序列,判断该序列是不是二叉搜索树的后序遍历序列 二叉搜索树定义: 二叉查找树(英语:Binary Search Tree),也称二叉搜索树、有序二叉树(英语:ordered binary tree) ,排序二叉树(英语:sorted binary tree),是指一棵空树或者具有下列性质的二叉树: 1、若任意节点的左子树不空,则左子树上所有结...
分类:其他好文   时间:2015-01-23 23:06:05    阅读次数:220
Populating Next Right Pointers in Each Node (DFS,没想到)
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe...
分类:其他好文   时间:2015-01-23 22:45:39    阅读次数:139
算法学习笔记(一):二分法及其实现
基本思想:二分法的一个前提是序列已经是有序的,然后将待查找值与序列的中点比较。根据比较结果,选择下一步比较的部分。二分查找(binary search)就是一个不断重复这一查找过程,直到找到这个值。算法复杂度:O(lgn)算法实现:一:迭代法int bin_search_iteration(int ...
分类:编程语言   时间:2015-01-23 21:23:08    阅读次数:201
LeetCode - Binary Search Tree Iterator
Binary Search Tree Iterator2015.1.23 18:58Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node ...
分类:其他好文   时间:2015-01-23 21:21:40    阅读次数:197
Flatten Binary Tree to Linked List (DFS)
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t...
分类:其他好文   时间:2015-01-23 21:17:22    阅读次数:252
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-01-23 19:56:34    阅读次数:202
Unique Binary Search Trees(dp)
Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1.....
分类:其他好文   时间:2015-01-23 18:16:13    阅读次数:236
Binary Tree Inorder Traversal
Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note...
分类:其他好文   时间:2015-01-23 17:46:36    阅读次数:121
[C++]LeetCode: 118 Find Peak Element (二分查找 寻找数组局部峰值)
题目: A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its index. The array may contain multiple pea...
分类:编程语言   时间:2015-01-23 16:22:13    阅读次数:185
【LeetCode】Minimum Depth of Binary Tree 二叉树的最小深度 java
【LeetCode】Minimum Depth of Binary TreeGiven a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path fro...
分类:编程语言   时间:2015-01-23 12:40:08    阅读次数:146
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!