首页 | 本学科首页   官方微博 | 高级检索  
     

基于KMP算法的改进算法KMPP
引用本文:李 莉,江育娥,林 劼,江秉华.基于KMP算法的改进算法KMPP[J].计算机工程与应用,2016,52(8):33-37.
作者姓名:李 莉  江育娥  林 劼  江秉华
作者单位:1.福建师范大学 软件学院,福州 350100 2.南京医科大学 病理系,南京 210029
摘    要:KMP算法和BM算法是经典的单模式匹配算法,但KMP算法中文本指针i]每次只能移动一个字符,整体的匹配效率并不高,结合KMP算法和BM算法的优点提出一种改进算法(KMPP)。算法的思想是模式串与文本在j]处不匹配时,预算出模式串移动nextj]]后末字符在文本中的位置,当该位置的文本字符与末字符不匹配时,则用该字符进行坏字符匹配,这两步的跳跃距离就是文本指针i]移动的距离,从而使指针i]每次移动的距离达到最大。实验结果表明,该算法匹配次数远低于KMP算法的匹配次数,提高了模式匹配的效率。

关 键 词:模式匹配  KMP算法  BM算法  KMPP算法  

Improved algorithm KMPP based on KMP
LI Li,JIANG Yu’e,LIN Jie,JIANG Binghua.Improved algorithm KMPP based on KMP[J].Computer Engineering and Applications,2016,52(8):33-37.
Authors:LI Li  JIANG Yu’e  LIN Jie  JIANG Binghua
Affiliation:1.Faculty of Software, Fujian Normal University, Fuzhou 350100, China 2.Department of Pathology, Nanjing Medical University, Nanjing 210029, China
Abstract:KMP algorithm and BM algorithm are classical single pattern matching algorithms, because the pointer i] in the text can only move one character at each time in KMP algorithm, the overall matching efficiency is not high, the improved algorithm(KMPP) accordingly to combine the advantages of the KMP algorithm with BM algorithm together is proposed. The core of KMPP algorithm is when a mismatch occurs at position j], it calculates the position in the text where the last character of pattern will align with after the pattern moving the value of nextj]]. If the last character of pattern does not match with the corresponding text position, the bad character rules are applied. The moving distance of pointer i] in the text is a two-step jumping distance, thus the pointer can move farthest at each time. The experimental result shows that the comparison number of KMPP algorithm is far less than the KMP algorithm’s number and it improves the efficiency of pattern matching algorithm.
Keywords:pattern matching  KMP algorithm  BM algorithm  KMPP algorithm  
点击此处可从《计算机工程与应用》浏览原始摘要信息
点击此处可从《计算机工程与应用》下载全文
设为首页 | 免责声明 | 关于勤云 | 加入收藏

Copyright©北京勤云科技发展有限公司  京ICP备09084417号