MCPcopy Index your code
hub / github.com/joowani/binarytree / max_leaf_depth

Method max_leaf_depth

binarytree/__init__.py:1419–1450  ·  view source on GitHub ↗

Return the maximum leaf node depth of the binary tree. :return: Maximum leaf node depth. :rtype: int **Example**: .. doctest:: >>> from binarytree import Node >>> >>> root = Node(1) >>> root.left = Node(2)

(self)

Source from the content-addressed store, hash-verified

1417
1418 @property
1419 def max_leaf_depth(self) -> int:
1420 """Return the maximum leaf node depth of the binary tree.
1421
1422 :return: Maximum leaf node depth.
1423 :rtype: int
1424
1425 **Example**:
1426
1427 .. doctest::
1428
1429 >>> from binarytree import Node
1430 >>>
1431 >>> root = Node(1)
1432 >>> root.left = Node(2)
1433 >>> root.right = Node(3)
1434 >>> root.right.left = Node(4)
1435 >>> root.right.left.left = Node(5)
1436 >>>
1437 >>> print(root)
1438 <BLANKLINE>
1439 1____
1440 / \\
1441 2 3
1442 /
1443 4
1444 /
1445 5
1446 <BLANKLINE>
1447 >>> root.max_leaf_depth
1448 3
1449 """
1450 return _get_tree_properties(self).max_leaf_depth
1451
1452 @property
1453 def min_leaf_depth(self) -> int:

Callers

nothing calls this directly

Calls 1

_get_tree_propertiesFunction · 0.85

Tested by

no test coverage detected