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

Function successorHelper

structure/tree/tree.go:173–189  ·  view source on GitHub ↗
(node, nilNode Node[T])

Source from the content-addressed store, hash-verified

171}
172
173func successorHelper[T constraints.Ordered](node, nilNode Node[T]) (T, bool) {
174 if node.Right() != nilNode {
175 return minimum(node.Right(), nilNode).Key(), true
176 }
177
178 p := node.Parent()
179 for p != nilNode && node == p.Right() {
180 node = p
181 p = p.Parent()
182 }
183
184 if p == nilNode {
185 var dft T
186 return dft, false
187 }
188 return p.Key(), true
189}

Callers

nothing calls this directly

Calls 4

minimumFunction · 0.85
RightMethod · 0.65
KeyMethod · 0.65
ParentMethod · 0.65

Tested by

no test coverage detected