Skip to content

Commit

Permalink
changed named to binary tree traversals
Browse files Browse the repository at this point in the history
  • Loading branch information
akshaysharma096 committed Sep 25, 2016
1 parent 9deae5d commit fb8d4a5
Showing 1 changed file with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,29 @@ def level_order(node):
q.put(node_dequeued.right)


node = build_tree()
if __name__ == '__main__':
import sys
print("\n********* Binary Tree Traversals ************\n")
# For python 2.x and 3.x compatibility: 3.x has not raw_input builtin
# otherwise 2.x's input builtin function is too "smart"
if sys.version_info.major < 3:
input_function = raw_input
else:
input_function = input

print("\n********* Pre Order Traversal ************")
pre_order(node)
print("\n******************************************\n")
node = build_tree()
print("\n********* Pre Order Traversal ************")
pre_order(node)
print("\n******************************************\n")

print("\n********* In Order Traversal ************")
in_order(node)
print("\n******************************************\n")
print("\n********* In Order Traversal ************")
in_order(node)
print("\n******************************************\n")

print("\n********* Post Order Traversal ************")
post_order(node)
print("\n******************************************\n")
print("\n********* Post Order Traversal ************")
post_order(node)
print("\n******************************************\n")

print("\n********* Level Order Traversal ************")
level_order(node)
print("\n******************************************\n")
print("\n********* Level Order Traversal ************")
level_order(node)
print("\n******************************************\n")

0 comments on commit fb8d4a5

Please sign in to comment.