为什么后缀树中出现的复杂度为Omn?

问题描述

| 基于此http://www.itu.dk/courses/AVA/E2005/StringIndexing.pdf 在第12/36页 给定字符串T [1 ... n],我们构建后缀树。搜索模式为P [1 ... m]。
• Preprocessing: O(n^2)
• Space: O(n^2)
• Occur(P in suffix tree): O(n*m) <===== why?
• Member is: O(m)
    

解决方法

您所指材料中的Occur(...)操作不是要从后缀树中搜索P,而是要找到最长的匹配项(即,找到在搜索树中出现的P的最长子串)并报告相应的叶子。最糟糕的情况是O(nm)操作,因为您需要使用P的每个后缀(即O(m)),并且可能每次报告O(n)都离开。     

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...