Return the height of the binary tree. Height of a binary tree is the number of edges on the longest path between the root node and a leaf node. Binary tree with just a single node has a height of 0. :return: Height of the binary tree. :rtype: int **
(self)
| 1010 | |
| 1011 | @property |
| 1012 | def height(self) -> int: |
| 1013 | """Return the height of the binary tree. |
| 1014 | |
| 1015 | Height of a binary tree is the number of edges on the longest path |
| 1016 | between the root node and a leaf node. Binary tree with just a single |
| 1017 | node has a height of 0. |
| 1018 | |
| 1019 | :return: Height of the binary tree. |
| 1020 | :rtype: int |
| 1021 | |
| 1022 | **Example**: |
| 1023 | |
| 1024 | .. doctest:: |
| 1025 | |
| 1026 | >>> from binarytree import Node |
| 1027 | >>> |
| 1028 | >>> root = Node(1) |
| 1029 | >>> root.left = Node(2) |
| 1030 | >>> root.left.left = Node(3) |
| 1031 | >>> |
| 1032 | >>> print(root) |
| 1033 | <BLANKLINE> |
| 1034 | 1 |
| 1035 | / |
| 1036 | 2 |
| 1037 | / |
| 1038 | 3 |
| 1039 | <BLANKLINE> |
| 1040 | >>> root.height |
| 1041 | 2 |
| 1042 | |
| 1043 | .. note:: |
| 1044 | A binary tree with only a root node has a height of 0. |
| 1045 | """ |
| 1046 | return _get_tree_properties(self).height |
| 1047 | |
| 1048 | @property |
| 1049 | def size(self) -> int: |
nothing calls this directly
no test coverage detected