- 4
- 0
- 约1.52万字
- 约 6页
- 2017-12-07 发布于贵州
- 举报
【精选】KMP算法中next数组的计算方法研究
计算机技术与发展 Vc,I.19№.6
第21090卷9年第6肯期年月 COIMpLrIER+FE(’HN()I』x:YAND 2009
DEVEI.OPMENT June
KMP算法中next数组的计算方法研究
汤亚玲
(安徽工业大学计算机学院,安徽马鞍山243002)
方式来计算next数组值。文中给出一种新的采用递归思想设计的计算ne氟数组的算法;并对当前数据结构教材中对next
数组定义的其它一些改进方式进行了讨论与分析。实验数据表明,递归算法的思想正确;并且,从算法设计上考虑,采用
递归方法设计的算法具有思路清晰、易于理解和分析的优点。
关键词:KMP;next数组;递推;递归
中图分类号:TP301.6 文献标识码:A 文章编号:1673—629X(2009)06一0098—04
Researchon ofNext
Design FuctionofKMP
Algorithm
TANG
Ya-ling
of of
(SchoolComputer,AnhuiUniversityTechnology,Maanshan243002,China)
Abstract:Itcalculatesthe valueOnthe ofreo.1rrenoeintextlx)oksof is and
usually ne,ct—array’8 way data—st“:uctu托.which
difficulty
kernelofKMP
algorithm.Introducesanewkindofalgorithm,which
caI池鹤Rex[一array’svalueby
cussionand on裂柚e definitionsof datashows
analysis superior next—array.Theexperiment itso饥Te吐n鹪oftherecursion
algorithm.
andtheretan鸭ion isalsoclearerandeasiertOunderstandon
algorithm algorithmdesignhag.
Keywords:KMP;next—array;recurrence;recursion
O引言 1 next数组定义
字符串(以下简称串)是一种重要的数据的结构, KMP算法避免不必要的回溯的关键在于,预先计
是一种特殊的线性表,它的数据对象是字符集合。计 算出模式串的next数组值,而模式串next数组值取决
算机在进行非数值运算时,大量使用串,串广泛应用于 于模式串自身的特点,与被匹配的
原创力文档

文档评论(0)