mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 20:26:07 -04:00
Create bt_height.py
This commit is contained in:
parent
75eb7e2dd9
commit
46b4f11520
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…
x
Reference in New Issue
Block a user