From 46b4f115209731dc83679f03c7d5f02ce6d1fb17 Mon Sep 17 00:00:00 2001 From: marina <138340846+bt3gl-cryptographer@users.noreply.github.com> Date: Thu, 3 Aug 2023 15:50:27 -0700 Subject: [PATCH] Create bt_height.py --- trees/bt_height.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 trees/bt_height.py diff --git a/trees/bt_height.py b/trees/bt_height.py new file mode 100644 index 0000000..65fa688 --- /dev/null +++ b/trees/bt_height.py @@ -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)) +