kmp 和boyer-moore
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Visualizing String Matching Algorithms</title> <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="javascript/strmatch.js"></script> <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.1/js/bootstrap.min.js"></script> <script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-45824317-1', 'whocouldthat.be');
ga('send', 'pageview');
</script> <style>
.monospace {
font-family: courier new;
font-size: 30px;
padding-bottom:20px;
min-width: 30px;
} .cell {
text-align: center;
} .options {
padding-top: 20px;
} #needle {
position:absolute;
} #haystack {
} .table-cell {
text-align: center;
width: 40px;
} .char-table {
table-layout: fixed;
} #links {
position:absolute;
bottom:0;
}
</style> </head>
<body> <a href="https://github.com/justinj/string-matching-visualization"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
<div id="main" class="container">
<form class="form-inline">
<div class="options"> <div class="algorithms form-group">
<div class="radio">
<label>
<input type="radio" name="algorithm" class="algbutton input" value="naive" checked="true"></radio>
Naïve
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="algorithm" class="algbutton" value="kmp"></radio>
KMP
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="algorithm" class="algbutton" value="boyer_moore"></radio>
Boyer-Moore
</label>
</div>
<br><label>Algorithm</label>
</div> <div class="form-group">
<label>
<input type="text" value="ABCDABD" maxlength="10" id="needle-input" class="form-control"></input> Needle
</label>
</div>
<div class="form-group">
<label>
<input type="text" value="ABC ABCDAB ABCDABCDABDE" maxlength="30" id="haystack-input" class="form-control"></input> Haystack
</label>
</div>
<br>
<input type="button" value="Animate" class="btn btn-default" id="animate"></input>
<input type="button" value="Step" class="btn btn-default" id="step"></input>
<input type="button" value="Reset" class="btn btn-default" id="reset"></input>
</div>
</form> <div class="result">
<div id="haystack" class="monospace"></div></br>
<div id="needle" class="monospace"></div>
</div>
<br><br><br><br>
<div class="row">
<div id="tables" class="col-sm-4"></div>
<div id="explanation" class="col-sm-4"></div>
</div>
<div class="row">
<div id="links">
<a href="http://en.wikipedia.org/wiki/String_matching">Wikipedia Article on String Matching</a><br>
<a href="http://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm">KMP Algorithm</a><br>
<a href="http://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string_search_algorithm">Boyer-Moore Algorithm</a><br>
</div>
</div>
</div> </div>
</body>
</html>
kmp 和boyer-moore的更多相关文章
- Boyer–Moore (BM)字符串搜索算法
在计算机科学里,Boyer-Moore字符串搜索算法是一种非常高效的字符串搜索算法.它由Bob Boyer和J Strother Moore设计于1977年.此算法仅对搜索目标字符串(关键字)进行预处 ...
- Boyer Moore算法(字符串匹配)
上一篇文章,我介绍了KMP算法. 但是,它并不是效率最高的算法,实际采用并不多.各种文本编辑器的"查找"功能(Ctrl+F),大多采用Boyer-Moore算法. Boyer-Mo ...
- Leetcode OJ : Implement strStr() [ Boyer–Moore string search algorithm ] python solution
class Solution { public: int strStr(char *haystack, char *needle) { , skip[]; char *str = haystack, ...
- 字符串问题简述与两个基本问题的Java实现——判断二叉树拓扑结构关系与变形词
转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6851631.html (解题金句:其他问题字符串化,然后调用String类封装方法解决问题: 字符串问题数组 ...
- grep之字符串搜索算法Boyer-Moore由浅入深(比KMP快3-5倍)
这篇长文历时近两天终于完成了,前两天帮网站翻译一篇文章“为什么GNU grep如此之快?”,里面提及到grep速度快的一个重要原因是使用了Boyer-Moore算法作为字符串搜索算法,兴趣之下就想了解 ...
- grep之字符串搜索算法Boyer-Moore由浅入深(比KMP快3-5倍)(转)
这篇长文历时近两天终于完成了,前两天帮网站翻译一篇文章“为什么GNU grep如此之快?”,里面提及到grep速度快的一个重要原因是使用了Boyer-Moore算法作为字符串搜索算法,兴趣之下就想了解 ...
- KMP算法简单回顾
前言 虽从事企业应用的设计与开发,闲暇之时,还是偶尔涉猎数学和算法的东西,本篇根据个人角度来写一点关于KMP串匹配的东西,一方面向伟人致敬,另一方面也是练练手,头脑风暴.我在自娱自乐,路过的朋友别太认 ...
- 字符串匹配常见算法(BF,RK,KMP,BM,Sunday)
今日了解了一下字符串匹配的各种方法. 并对sundaysearch算法实现并且单元. 字符串匹配算法,是在实际工程中经常遇到的问题,也是各大公司笔试面试的常考题目.此算法通常输入为原字符串(strin ...
- Majority Element问题---Moore's voting算法
Leetcode上面有这么一道难度为easy的算法题:找出一个长度为n的数组中,重复次数超过一半的数,假设这样的数一定存在.O(n2)和O(nlog(n))(二叉树插入)的算法比较直观.Boyer–M ...
- Boyer-Moore 字符串匹配算法
字符串匹配问题的形式定义: 文本(Text)是一个长度为 n 的数组 T[1..n]: 模式(Pattern)是一个长度为 m 且 m≤n 的数组 P[1..m]: T 和 P 中的元素都属于有限的字 ...
随机推荐
- [Effective JavaScript 笔记]第19条:熟练掌握高阶函数
高阶函数介绍 高阶函数曾经是函数式编程的一个概念,感觉是很高深的术语.但开发简洁优雅的函数可以使代码更加简单明了.过去几年中脚本语言采用了这些个技术,揭开了函数式编程的最佳惯用法的神秘面纱.高阶函数就 ...
- DataSnap 用TStream 传递大数据 返回流大小为-1的情况
DataSnap可以直接传递和返回TStream类型的参数,这点是很方便的.但是很多人发现好像大小稍微大点就工作不正常了,就变相使用其它类型转换来转换去,这样便利性就失去了. 官方有篇博客很详细的介绍 ...
- http://www.zhihu.com/question/24896283
http://www.zhihu.com/question/24896283 Rix Tox,太不專業了 三百.知乎用户.raintorr 等人赞同 1. 更改变量名的几种方法这种情况下该如何快速选中 ...
- 【Network】一张图看懂 Reactor 与 Proactor 模型的区别
首先来看看Reactor模式,Reactor模式应用于同步I/O的场景.我们以读操作为例来看看Reactor中的具体步骤:读取操作:1. 应用程序注册读就需事件和相关联的事件处理器2. 事件分离器等待 ...
- makefile文件编写
文件转载自:http://www.cppblog.com/lapcca/archive/2010/11/26/134714.html 下面这篇文章讲的很清楚,基本的用法也很简单. 一.Makefi ...
- JSON: property "xxx" has no getter method in class "..."
Exception in thread "main" net.sf.json.JSONException: java.lang.NoSuchMethodException: Pro ...
- 45. Singleton类的C++/C#实现[Singleton]
[题目] 设计一个类,我们只能生成该类的一个实例. [分析] 单例模式的意图是保证一个类仅有一个实例,并提供一个访问它的全局访问点.让类自身负责保存它的唯一实例.这个类可以保证没有其他实例可.以被创建 ...
- CAS单点登录之mysql数据库用户验证及常见问题
前面已经介绍了CAS服务器的搭建,详情见:搭建CAS单点登录服务器.然而前面只是简单地介绍了服务器的搭建,其验证方式是原始的配置文件的方式,这显然不能满足日常的需求.下面介绍下通过mysql数据库认证 ...
- android.content.ActivityNotFoundException: Unable to find explicit activity class have you declared this activity in your AndroidManifest.xml?
在整合PullToRefresh的时候出现如下异常 10-22 23:20:01.826 32331-32331/com.example.news.andoridnewsapp E/AndroidRu ...
- Android dp px转化公式
// DisplayMetrics metrics = getResources().getDisplayMetrics(); // int statusBarHeight = (int) Math. ...