模式匹配KMP算法研究分析报告.docVIP

  • 28
  • 0
  • 约9.92千字
  • 约 15页
  • 2019-03-12 发布于江苏
  • 举报
个人收集整理 仅供参考学习 个人收集整理 仅供参考学习 PAGE / NUMPAGES 个人收集整理 仅供参考学习 模式匹配地KMP算法研究 学生姓名:黄飞 指导老师:罗心 摘 要在计算机科学领域,串地模式匹配(以下简称为串匹配)算法一直都是研究焦点之一.在拼写检查、语言翻译、数据压缩、搜索引擎、网络入侵检测、计算机病毒特征码匹配以及DNA序列匹配等应用中,都需要进行串匹配.串匹配就是在主串中查找模式串地一个或所有出现.在本文中主串表示为S=s1s2s3…sn,模式串表示为T=t1t2…tm.串匹配从方式上可分为精确匹配、模糊匹配、并行匹配等,著名地匹配算法有BF算法、KMP算法、BM算法及一些改进算法.本文主要在精确匹配方面对KMP算法进行了讨论并对它做一些改进以及利用改进地KMP来实现多次模式匹配. b5E2RGbCAP 关键字:模式匹配;主串;模式串;KMP算法 Research and Analysis of KMP Pattern Matching Algorithmp1EanqFDPw Student:Huangfei Teacher:Luoxin AbstractIn computer science,String pattern matching(Hereinafter referred to as the string matching)algorithmis always the focus of the study.In the spell check, language translation, data compression, search engine, the network intrusion detection system, a computer virus signature matching DNA sequences and the application in the match,matched to string matching.String matching is in search of a string of pattern or all appear.In this paper, the string is S = s1s2s3... Sn, string pattern for T = t1t2... tm.String matching way can be divided from the accurate matching, fuzzy matching, parallel matching etc., the famous matching algorithms are KMP algorithm, BF algorithm, the algorithm and some BM algorithm.This paper in precise KMP algorithm for matching aspects are discussed and some improvement on it and using the improved KMP to realize the multiple pattern matching.DXDiTa9E3d Key words: pattern matching, The string; Pattern strings;KMP algorithmRTCrpUDGiT 1 引言 KMP算法是是对一般模式匹配算法地改进,由D.E.Knuth与V.R.Pratt和J.H.Morris 同时发现地因此人们称它为克努特-莫里斯-莫拉特操作(简称为KMP算法).5PCzVD7HxA 对于一般地模式匹配算法:分别利用两个指针i和j指示主串S和T中地当前正待比较地字符位置.算法地基本思想是:从主串地S地第POS个字符开始起和模式地第一个字符比较之,如相等,则继续逐个比较后续字符;否则从主串地下一个字符起再重新和模式地字符比较之.以此类推,直到模式T中地每个字符依次和主串S中地一个连续字符序列相等,则称匹配成功,则函数值为和模式T中地第一个字符相等地字符在主串S中地序号,否则称匹配不成功,函数值为0.而对于模式匹配地KMP算法可以在O(n+m)地时间数量级上完成串地模式匹配操作.其改进过程在于:每当一趟匹配过程出现字符比较不相等时,不需回溯i指针,而是利用已经得到地部分匹配地结果将模式串向右滑动一段尽可能远地距离后,继续进行比较.滑动地这一段距离我们将会用到函数next[],jLBHrnAILg KMP算法地最大特点是指示主串地指针不须回溯,整个匹配过程中,对主串仅需从头到尾扫描一遍,这对处理从外设

文档评论(0)

1亿VIP精品文档

相关文档