
算法/思想
文章平均质量分 75
xgdofull
这个作者很懒,什么都没留下…
展开
-
KMP和BM算法
The Boyer-Moore Fast String Searching AlgorithmThis algorithm, which Bob Boyer and I invented in about 1975, is the basis of the fastest known ways to find one string of characters in another. How m转载 2010-03-16 15:28:00 · 1189 阅读 · 0 评论 -
BM算法(java版)
package test;public class BM { /** * @param c 主串(源串)中的字符 * @param T 模式串(目标串)字符数组 * @return 滑动距离 */ private static int dist(char c, char T[]) { int n = T.length; if (c == T[n - 1]) { return原创 2010-03-22 11:29:00 · 4175 阅读 · 3 评论 -
KMP算法(java版)
package test;import org.apache.commons.lang.ArrayUtils;public class KMP3 {private static int[] failFunc(String pattern) {int pLen = pattern.length();// the fail functionint failFunc[] = new int[转载 2010-03-22 14:33:00 · 829 阅读 · 0 评论 -
位图bitmap算法(java)
简单的说就是用数组存放若有数据就标志为1或true,若不存在标志为0或false。比如1,2,2,5,这里最大值为5,0至5中不存0,3,4,所以:Array[0]=0,Array[1]=1,Array[2]=2,Array[3]=0,Array[4]=0,Array[5]=1上面数中由于2有两个,所以用int存数组的值,不用boolean型,这样如果有多个同样的数字可以用值表示个数。如上原创 2010-03-28 13:53:00 · 19632 阅读 · 5 评论 -
约瑟夫环的2种解决
问题:一共n个人,查到m的人出圈,求最后圈里的人是几号。 public class YusefuTest { /** * 返回最后一个出列的人数 * * @param n * @param m * @return */ private static int YSF1(int n, int m) { int r = 0; for (int i = 2; i原创 2010-03-28 21:48:00 · 804 阅读 · 0 评论 -
最长公共子串
import java.util.ArrayList;import java.util.List;/** * 最长公共子串。下面是矩阵方法求的,也就是对角线最长的即为最长公共子串 * @author xiong * */public class LCS { private static List getLCS(String str1, String str2) { if (str1 ==原创 2010-03-28 21:58:00 · 473 阅读 · 0 评论 -
关键字过滤
package filter; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; impo转载 2012-12-05 19:57:57 · 1416 阅读 · 0 评论