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

Method Insert

project_euler/problem_18/leaf.go:46–59  ·  view source on GitHub ↗
(node Node)

Source from the content-addressed store, hash-verified

44}
45
46func (n *Leaf) Insert(node Node) {
47 // If Left is nil, always simply insert the node
48 if n.NodeLeft == nil {
49 node.SetParent(n)
50 n.NodeLeft = node.(*Leaf)
51
52 return
53 }
54
55 // If Right is nil, insert the node
56 n.NodeRight = node.(*Leaf)
57 // Send it to the sibling right
58 n.Parent.Right().Insert(node)
59}
60
61func (n *Leaf) HasSpace() bool {
62 return n.NodeLeft == nil || n.NodeRight == nil

Callers

nothing calls this directly

Calls 3

SetParentMethod · 0.65
InsertMethod · 0.65
RightMethod · 0.65

Tested by

no test coverage detected