一种时间复杂度最优的精确串匹配算法  被引量:25

A Time Optimal Exact String Matching Algorithm

在线阅读下载全文

作  者:贺龙涛[1] 方滨兴[1] 余翔湛[1] 

机构地区:[1]哈尔滨工业大学计算机网络与信息安全技术研究中心,黑龙江哈尔滨150001

出  处:《软件学报》2005年第5期676-683,共8页Journal of Software

基  金:国家高技术研究发展计划863;国家"九五"国防预研基金~~

摘  要:现有的串匹配算法通常以模式长度作为滑动窗口大小.在窗口移动后,往往会丢弃掉一些已扫描正文的信息.提出了LDM(linear DAWG matching)串匹配算法,该算法将正文分为[n/m]个相互重叠、大小为2m?1的扫描窗口.在每个扫描窗口内,算法批量地尝试m个可能位置,首先使用反向后缀自动机从窗口中间位置向前扫描模式前缀;若成功,则再使用正向有限状态自动机从中间位置向后扫描剩余的模式后缀.分析证明,LDM算法的最差、最好、平均时间复杂度分别达到了理论最好结果:O(n),O(n/m),O(n(logσm)/m).实际性能测试也验证了平均时间复杂度最优这一理论结果.而且,对于在较大字母表下查找短模式的情况,LDM算法速度在被测试算法中最快.总之,LDM算法不但适合进行离线模式匹配,而且还特别适合需要进行在线高速匹配的应用.Existing string matching algorithms typically set the sliding window size as the pattern length. This paper presents a Linear DAWG Matching (LDM) algorithm, which divides the text into [n/m] overlapping windows of length 2m?1. In the windows, the algorithm attempts at m positions in batches. It firstly searches pattern prefixes from middle to left with a reversed suffix automaton, shifts to next window directly when it fails, otherwise, scans the corresponding suffixes forward with a finite automaton. Theoretical analysis shows that LDM has optimal time complexities in the worst (O(m)), best (O(n/m)) and average cases (O(n(logσm)/m)). Experimental comparison of LDM with the existing algorithms validates this theoretical claims of average case for searching long patterns. It further reveals that LDM is also efficient for searching short patterns on large alphabets. Thus, LDM algorithm not only suits for off-line pattern matching, but also fits in high-speed online pattern matching.

关 键 词:后缀自动机 有限状态自动机 LDM算法 串匹配 复杂度分析 

分 类 号:TP301[自动化与计算机技术—计算机系统结构]

 

参考文献:

正在载入数据...

 

二级参考文献:

正在载入数据...

 

耦合文献:

正在载入数据...

 

引证文献:

正在载入数据...

 

二级引证文献:

正在载入数据...

 

同被引文献:

正在载入数据...

 

相关期刊文献:

正在载入数据...

相关的主题
相关的作者对象
相关的机构对象