题目:
Given a 2D board and a word, find if the word exists in the grid.
The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or ver...
分类:
编程语言 时间:
2015-01-15 16:14:27
阅读次数:
301
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent
a number.
An example is the root-to-leaf path 1->2->3 which represents the number 123.
Find the tota...
分类:
其他好文 时间:
2015-01-15 09:26:49
阅读次数:
117
深度优先搜索算法在搜索过程中对节点进行涂色来指明节点的当前状态. 每个节点的初始颜色都是白色. 在节点被发现后变成灰色. 在其邻接链表被扫描完成之后变成黑色. 该方法可以保证每个节点只在一棵深度优先树中出现, 因此, 所有的深度优先树是不相交(disjoint)的. 除了创建深度优先搜索森林之外, ...
分类:
其他好文 时间:
2015-01-14 19:39:43
阅读次数:
532
DFS 从图中某个顶点V0 出发,访问此顶点,然后依次从V0的各个未被访问的邻接点出发深度优先搜索遍历图,直至图中所有和V0有路径相通的顶点都被访问到(使用堆栈). //使用邻接矩阵存储的无向图的深度优先遍历
template
void Graph::DFS()
{
stack iStack;
showVertex(0);
vertexList[0]->wasVi...
分类:
其他好文 时间:
2015-01-14 16:55:55
阅读次数:
204
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.
For example:
Given the below binary tree and sum
= 22,
5
/ ...
分类:
其他好文 时间:
2015-01-14 16:55:08
阅读次数:
202
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 never diffe...
分类:
其他好文 时间:
2015-01-14 15:33:12
阅读次数:
141
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
For example, this binary tree is symmetric:
1
/ 2 2
/ \ / 3 4 4 3
But the f...
分类:
其他好文 时间:
2015-01-14 11:08:56
阅读次数:
154
Given two binary trees, write a function to check if they are equal or not.
Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
/**
* Defin...
分类:
其他好文 时间:
2015-01-14 09:48:40
阅读次数:
139
首先要感谢上海大学的kuangbin大神,他正在VJ上开一个又一个的专题,为了让我这种弱渣入门。 从今天开始我就要根据bin神专题来进行学习和刷题了。 首先第一个专题就是搜索,先是基础搜索。 基础的搜索包括 DFS(深度优先搜索),BFS(广度优先搜索),回溯搜索,双向广度搜索,枚举搜...
分类:
其他好文 时间:
2015-01-12 23:54:54
阅读次数:
350
这是一道纯正的深度优先搜索题目。题目要求在有多少个不同的块,而不同块的定义则是,一个块中的任意一点和l另一个块中的任意一点不会相连,而相连的定义则是在横向、纵向和对角线上相连。#include#includechar map[101][101];int m,n;int search(int x,in...
分类:
其他好文 时间:
2015-01-12 20:44:03
阅读次数:
111