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

Method insert

structure/trie/trie.go:22–33  ·  view source on GitHub ↗

insert a single word at a Trie node.

(s string)

Source from the content-addressed store, hash-verified

20
21// insert a single word at a Trie node.
22func (n *Node) insert(s string) {
23 curr := n
24 for _, c := range s {
25 next, ok := curr.children[c]
26 if !ok {
27 next = NewNode()
28 curr.children[c] = next
29 }
30 curr = next
31 }
32 curr.isLeaf = true
33}
34
35// Insert zero, one or more words at a Trie node.
36func (n *Node) Insert(s ...string) {

Callers 1

InsertMethod · 0.95

Calls 1

NewNodeFunction · 0.70

Tested by

no test coverage detected