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

Method Insert

project_euler/problem_18/edge.go:63–84  ·  view source on GitHub ↗
(node Node)

Source from the content-addressed store, hash-verified

61}
62
63func (n *Edge) Insert(node Node) {
64 // If Left is nil, always simply insert the node
65 if n.NodeLeft == nil {
66 node.SetParent(n)
67 n.NodeLeft = node
68
69 return
70 }
71
72 // If Right is nil, insert the node
73 n.NodeRight = node
74
75 // If the node to insert is an edge, set the parent
76 if node.Kind() == "edge" {
77 node.SetParent(n)
78
79 return
80 }
81
82 // If the node to insert is a leaf, send it to the sibling right
83 n.Parent.Right().Insert(node)
84}
85
86func (n *Edge) HasSpace() bool {
87 return n.NodeLeft == nil || n.NodeRight == nil

Callers

nothing calls this directly

Calls 4

SetParentMethod · 0.65
KindMethod · 0.65
InsertMethod · 0.65
RightMethod · 0.65

Tested by

no test coverage detected