MCPcopy Create free account
hub / github.com/geekcomputers/Python / depth

Function depth

binary_search_tree.py:337–346  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

335
336
337def depth(node):
338 if node is None:
339 return 0
340 l_depth, r_depth = 0, 0
341 if node.left:
342 l_depth = depth(node.left)
343 if node.right:
344 r_depth = depth(node.right)
345 # print(node.info, l_depth, r_depth)
346 return 1 + max(l_depth, r_depth)
347
348
349t = BinarySearchTree()

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected