mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-02 06:46:18 -04:00
Create bt_height.py
This commit is contained in:
parent
75eb7e2dd9
commit
46b4f11520
1 changed files with 9 additions and 0 deletions
9
trees/bt_height.py
Normal file
9
trees/bt_height.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# author: bt3gl
|
||||
|
||||
def height(root):
|
||||
if not root:
|
||||
return -1
|
||||
return 1 + max(height(root.left), height(root.right))
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue