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

Function calculateDepth

structure/tree/tree.go:106–112  ·  view source on GitHub ↗
(n, nilNode Node[T], depth int)

Source from the content-addressed store, hash-verified

104}
105
106func calculateDepth[T constraints.Ordered](n, nilNode Node[T], depth int) int {
107 if n == nilNode {
108 return depth
109 }
110
111 return max.Int(calculateDepth(n.Left(), nilNode, depth+1), calculateDepth(n.Right(), nilNode, depth+1))
112}
113
114func minimum[T constraints.Ordered](node, nilNode Node[T]) Node[T] {
115 if node == nilNode {

Callers

nothing calls this directly

Calls 3

IntFunction · 0.92
LeftMethod · 0.65
RightMethod · 0.65

Tested by

no test coverage detected