Binary Tree Zigzag Level Order TraversalTotal Accepted:31183Total Submissions:117840My SubmissionsQuestionSolutionGiven a binary tree, return thezigza...
分类:
其他好文 时间:
2015-04-17 21:53:46
阅读次数:
123
#include#include#includeusing namespace std;// Definition for binary tree struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int...
分类:
其他好文 时间:
2015-04-17 21:51:07
阅读次数:
141
题目链接: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 tree in which the depth of the two subtrees ...
分类:
其他好文 时间:
2015-04-17 18:17:21
阅读次数:
140
题目链接: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.
这道题的要求是将有序链表转化成高度平衡的二叉搜索树(BST)。
1. 利...
分类:
其他好文 时间:
2015-04-17 18:16:32
阅读次数:
165
题目链接:Binary Tree Level Order Traversal
II
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).
For exam...
分类:
其他好文 时间:
2015-04-17 18:16:21
阅读次数:
176
题目链接:Construct
Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in th...
分类:
其他好文 时间:
2015-04-17 18:15:57
阅读次数:
159
题目链接:Convert Sorted Array
to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
这道题的要求是将有序数组转化成高度平衡的二叉搜索树(BST)。
由于数组有序,因此相当于二叉搜索树...
分类:
其他好文 时间:
2015-04-17 18:15:21
阅读次数:
187
描述从根节点开始的递归深度优先搜索与树的前序遍历(preorder traversal)类似,是前序遍历的推广。从某个顶点V开始处理,然后递归地遍历所有与顶点V邻接的且没有被访问过的顶点。算法的基本思想如下:
假设图G初态为所有顶点未被访问(visited[i]=false),从G中任选一顶点vi :
从该顶点vi出发,首先访问vi,,置visited [vi ]=true;
然后依次搜索vi的每...
分类:
其他好文 时间:
2015-04-17 15:52:07
阅读次数:
217
1. 使用深度优先算法遍历下图,遍历的顺序为()
A ABCDEFG B ABDCFEG
C ABDECFG D ABCDFEG
分析:
答案C
2. 输入序列ABCABC经过栈操作变成ABCCBA,下面哪些是可能的栈操作( )
A. push pop push pop push po...
分类:
其他好文 时间:
2015-04-17 15:49:10
阅读次数:
570
算法图搜索(广度优先、深度优先)深度优先特别重要排序动态规划匹配算法和网络流算法正则表达式和字符串匹配数据结构图 (树尤其重要)Map堆栈/队列Tries | 字典树额外推荐贪婪算法概率方法近似算法算法:三路划分-快速排序合并排序(更具扩展性,复杂度类似快速排序)DF/BF 搜索 (要知道使用场景)...
分类:
编程语言 时间:
2015-04-17 11:09:01
阅读次数:
191