File tree Expand file tree Collapse file tree 1 file changed +2
-1
lines changed Expand file tree Collapse file tree 1 file changed +2
-1
lines changed Original file line number Diff line number Diff line change 2
2
# , p is the number of patterns
3
3
# query: O(m + z), m is the total size of query string
4
4
# , z is the number of all matched strings
5
+ # , query would be O(m) if we don't use all the matched patterns
5
6
# Space: O(t + p^2), t is the total size of ac automata trie
6
7
# , space could be further improved by DAT (double-array trie)
7
8
@@ -26,7 +27,7 @@ def step(self, letter):
26
27
while self .__node and letter not in self .__node .children :
27
28
self .__node = self .__node .suffix
28
29
self .__node = self .__node .children [letter ] if self .__node else self .__root
29
- return self .__node .outputs # Time: O(z)
30
+ return self .__node .outputs # Time: O(z), it would be O(m) if we don't use all the matched patterns
30
31
31
32
def __init__ (self , patterns ):
32
33
self .__root = self .__create_ac_trie (patterns )
You can’t perform that action at this time.
0 commit comments