Skip to content

InOrder Traversal for Binary Tree #748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions binary_tree/basic_binary_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ def __init__(self, data):
self.left = None
self.right = None

def display(tree): #In Order traversal of the tree

if tree is None:
return

if tree.left is not None:
display(tree.left)

print(tree.data)

if tree.right is not None:
display(tree.right)

return

def depth_of_tree(tree): #This is the recursive function to find the depth of binary tree.
if tree is None:
Expand Down Expand Up @@ -41,6 +55,8 @@ def main(): # Main func for testing.

print(is_full_binary_tree(tree))
print(depth_of_tree(tree))
print("Tree is: ")
display(tree)


if __name__ == '__main__':
Expand Down