MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / Successor

Method Successor

structure/tree/bstree.go:157–164  ·  view source on GitHub ↗

Successor returns the Successor of the node of Key if there is no successor, return default value of type T and false otherwise return the Key of successor and true

(key T)

Source from the content-addressed store, hash-verified

155// if there is no successor, return default value of type T and false
156// otherwise return the Key of successor and true
157func (t *BinarySearch[T]) Successor(key T) (T, bool) {
158 node, ok := searchTreeHelper[T](t.Root, t._NIL, key)
159 if !ok {
160 var dft T
161 return dft, ok
162 }
163 return successorHelper[T](node, t._NIL)
164}
165
166func (t *BinarySearch[T]) pushHelper(x *BSNode[T], val T) {
167 y := t._NIL

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected