MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / insert

Method insert

data_structures/trie/trie.py:23–34  ·  view source on GitHub ↗

Inserts a word into the Trie :param word: word to be inserted :return: None

(self, word: str)

Source from the content-addressed store, hash-verified

21 self.insert(word)
22
23 def insert(self, word: str) -> None:
24 """
25 Inserts a word into the Trie
26 :param word: word to be inserted
27 :return: None
28 """
29 curr = self
30 for char in word:
31 if char not in curr.nodes:
32 curr.nodes[char] = TrieNode()
33 curr = curr.nodes[char]
34 curr.is_leaf = True
35
36 def find(self, word: str) -> bool:
37 """

Callers 1

insert_manyMethod · 0.95

Calls 1

TrieNodeClass · 0.85

Tested by

no test coverage detected