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

Function main

data_structures/suffix_tree/example/example_usage.py:12–33  ·  view source on GitHub ↗

Demonstrate the usage of the SuffixTree class. - Initializes a SuffixTree with a predefined text. - Defines a list of patterns to search for within the suffix tree. - Searches for each pattern in the suffix tree. Patterns tested: - "ana" (found) --> True - "ban

()

Source from the content-addressed store, hash-verified

10
11
12def main() -> None:
13 """
14 Demonstrate the usage of the SuffixTree class.
15
16 - Initializes a SuffixTree with a predefined text.
17 - Defines a list of patterns to search for within the suffix tree.
18 - Searches for each pattern in the suffix tree.
19
20 Patterns tested:
21 - "ana" (found) --> True
22 - "ban" (found) --> True
23 - "na" (found) --> True
24 - "xyz" (not found) --> False
25 - "mon" (found) --> True
26 """
27 text = "monkey banana"
28 suffix_tree = SuffixTree(text)
29
30 patterns = ["ana", "ban", "na", "xyz", "mon"]
31 for pattern in patterns:
32 found = suffix_tree.search(pattern)
33 print(f"Pattern '{pattern}' found: {found}")
34
35
36if __name__ == "__main__":

Callers 1

example_usage.pyFile · 0.70

Calls 2

searchMethod · 0.95
SuffixTreeClass · 0.90

Tested by

no test coverage detected