MCPcopy Create free account
hub / github.com/subbarayudu-j/TheAlgorithms-Python / insert

Method insert

data_structures/trie/trie.py:24–35  ·  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

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

Callers 1

insert_manyMethod · 0.95

Calls 1

TrieNodeClass · 0.85

Tested by

no test coverage detected