MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / _add_suffix

Method _add_suffix

data_structures/suffix_tree/suffix_tree.py:34–49  ·  view source on GitHub ↗

Adds a suffix to the suffix tree. Args: suffix (str): The suffix to add. index (int): The starting index of the suffix in the original text.

(self, suffix: str, index: int)

Source from the content-addressed store, hash-verified

32 self._add_suffix(suffix, i)
33
34 def _add_suffix(self, suffix: str, index: int) -> None:
35 """
36 Adds a suffix to the suffix tree.
37
38 Args:
39 suffix (str): The suffix to add.
40 index (int): The starting index of the suffix in the original text.
41 """
42 node = self.root
43 for char in suffix:
44 if char not in node.children:
45 node.children[char] = SuffixTreeNode()
46 node = node.children[char]
47 node.is_end_of_string = True
48 node.start = index
49 node.end = index + len(suffix) - 1
50
51 def search(self, pattern: str) -> bool:
52 """

Callers 1

build_suffix_treeMethod · 0.95

Calls 1

SuffixTreeNodeClass · 0.90

Tested by

no test coverage detected