Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit56de3df

Browse files
Ahish9009poyea
authored andcommitted
Update basic_binary_tree.py (TheAlgorithms#748)
1 parent15bc87f commit56de3df

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎binary_tree/basic_binary_tree.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ def __init__(self, data):
44
self.left=None
55
self.right=None
66

7+
defdisplay(tree):#In Order traversal of the tree
8+
9+
iftreeisNone:
10+
return
11+
12+
iftree.leftisnotNone:
13+
display(tree.left)
14+
15+
print(tree.data)
16+
17+
iftree.rightisnotNone:
18+
display(tree.right)
19+
20+
return
721

822
defdepth_of_tree(tree):#This is the recursive function to find the depth of binary tree.
923
iftreeisNone:
@@ -41,6 +55,8 @@ def main(): # Main func for testing.
4155

4256
print(is_full_binary_tree(tree))
4357
print(depth_of_tree(tree))
58+
print("Tree is: ")
59+
display(tree)
4460

4561

4662
if__name__=='__main__':

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp