Skip to content

Commit 6ea9257

Browse files
authored
Update stream-of-characters2.py
1 parent 93d7f3d commit 6ea9257

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Python/stream-of-characters2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# , p is the number of patterns
33
# query: O(m + z), m is the total size of query string
44
# , z is the number of all matched strings
5+
# , query would be O(m) if we don't use all the matched patterns
56
# Space: O(t + p^2), t is the total size of ac automata trie
67
# , space could be further improved by DAT (double-array trie)
78

@@ -26,7 +27,7 @@ def step(self, letter):
2627
while self.__node and letter not in self.__node.children:
2728
self.__node = self.__node.suffix
2829
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
3031

3132
def __init__(self, patterns):
3233
self.__root = self.__create_ac_trie(patterns)

0 commit comments

Comments
 (0)