Recursive function for calculating the height of the binary tree. >>> height(None) 0 >>> height(make_tree()) 3
(root: Node | None)
| 83 | |
| 84 | |
| 85 | def height(root: Node | None) -> int: |
| 86 | """ |
| 87 | Recursive function for calculating the height of the binary tree. |
| 88 | >>> height(None) |
| 89 | 0 |
| 90 | >>> height(make_tree()) |
| 91 | 3 |
| 92 | """ |
| 93 | return (max(height(root.left), height(root.right)) + 1) if root else 0 |
| 94 | |
| 95 | |
| 96 | def level_order(root: Node | None) -> Generator[int]: |