We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 365434e commit bfd63f1Copy full SHA for bfd63f1
NonLinearDataStruc/tree/bst.py
@@ -58,6 +58,12 @@ def findMaxNode(root): # most right
58
return root.value, size
59
60
61
+def max_depth(root):
62
+ if not root:
63
+ return 0
64
+ return 1 + max(max_depth(root.left), max_depth(root.right))
65
+
66
67
def invertTree(root):
68
if not root:
69
return None
@@ -127,6 +133,9 @@ def deleteNode(root, value): # ******* important **********
127
133
print('\n')
128
134
print(f"Min val & size of BST: {findMinNode(rt)}, Max val & size of BST: {findMaxNode(rt)}")
129
135
136
+print('\n')
137
+print(f"Max depth of bst: {max_depth(rt)}")
138
130
139
print('\nInvert Tree: left is right & right is left.')
131
140
invertTree(rt)
132
141
print('pre-order(root->left->right):')
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments