The gray code is a binary numeral system where two successive valuesdiffer in only one bit.
Given a non-negative integer n representing the totalnumber of bits in the code, print the sequence of gray...
分类:
其他好文 时间:
2015-02-11 09:24:25
阅读次数:
233
题目链接:Multiply Strings
Implement wildcard pattern matching with support for '?' and '*'.
'?' Matches any single character.
'*' Matches any sequence of characters (including the empty sequence).
...
分类:
其他好文 时间:
2015-02-10 09:16:45
阅读次数:
228
上一篇写了DFS的邻接矩阵和邻接表的,这篇再写一下BFS的
先大概讲一下BFS , 全名广度优先搜索,没有回溯和探查,逐层遍历,采用队列实现
先访问当前顶点v, 然后访问v的各个未被访问过的邻接顶点,然后在一次访问v的各个邻接顶点的未被访问的邻接顶点
代码实现如下 :
void BFS (Graph &G , int v ) {
int i , w , n = G.Number(); /...
分类:
编程语言 时间:
2015-02-07 17:29:05
阅读次数:
183
题目链接:Combination Sum II
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.
Each number in C may only be use...
分类:
其他好文 时间:
2015-02-06 21:48:23
阅读次数:
290
题目链接:Combination Sum
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.
The same repeated number may be chosen fro...
分类:
其他好文 时间:
2015-02-06 21:47:21
阅读次数:
158
题目链接:Sudoku Solver
Write a program to solve a Sudoku puzzle by filling the empty cells.
Empty cells are indicated by the character '.'.
You may assume that there will be only one unique solution.
...
分类:
其他好文 时间:
2015-02-06 00:49:25
阅读次数:
155
uva 11218 KTV
One song is extremely popular recently, so you and your friends decided to sing it in KTV. The song has 3 characters, so exactly 3 people should sing together each time (yes, ther...
分类:
其他好文 时间:
2015-02-05 18:35:13
阅读次数:
171
一、基本描述类似于回溯法,也是一种在问题的解空间树T上搜索问题解的算法。但在一般情况下,分支限界法与回溯法的求解目标不同。回溯法的求解目标是找出T中满足约束条件的所有解,而分支限界法的求解目标则是找出满足约束条件的一个解,或是在满足约束条件的解中找出使某一目标函数值达到极大或极小的解,即在某种意义下...
分类:
编程语言 时间:
2015-02-05 13:03:16
阅读次数:
200
1、概念回溯算法实际上一个类似枚举的搜索尝试过程,主要是在搜索尝试过程中寻找问题的解,当发现已不满足求解条件时,就“回溯”返回,尝试别的路径。回溯法是一种选优搜索法,按选优条件向前搜索,以达到目标。但当探索到某一步时,发现原先选择并不优或达不到目标,就退回一步重新选择,这种走不通就退回再走的技术为回...
分类:
编程语言 时间:
2015-02-05 12:49:47
阅读次数:
232
uva 307 Sticks
George took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants to return sticks to the original state, but he forgot how m...
分类:
其他好文 时间:
2015-02-04 16:47:33
阅读次数:
187