MCPcopy
hub / github.com/TheAlgorithms/Go / searchTreeHelper

Function searchTreeHelper

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

Source from the content-addressed store, hash-verified

50}
51
52func searchTreeHelper[T constraints.Ordered](node, nilNode Node[T], key T) (Node[T], bool) {
53 if node == nilNode {
54 return node, false
55 }
56
57 if key == node.Key() {
58 return node, true
59 }
60 if key < node.Key() {
61 return searchTreeHelper(node.Left(), nilNode, key)
62 }
63 return searchTreeHelper(node.Right(), nilNode, key)
64}
65
66func inOrderHelper[T constraints.Ordered](node, nilNode Node[T]) []T {
67 var stack []Node[T]

Callers

nothing calls this directly

Calls 3

KeyMethod · 0.65
LeftMethod · 0.65
RightMethod · 0.65

Tested by

no test coverage detected