mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
changed named to binary tree traversals
This commit is contained in:
parent
9deae5d14c
commit
fb8d4a5387
@ -77,20 +77,29 @@ def level_order(node):
|
|||||||
q.put(node_dequeued.right)
|
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 ************")
|
node = build_tree()
|
||||||
pre_order(node)
|
print("\n********* Pre Order Traversal ************")
|
||||||
print("\n******************************************\n")
|
pre_order(node)
|
||||||
|
print("\n******************************************\n")
|
||||||
|
|
||||||
print("\n********* In Order Traversal ************")
|
print("\n********* In Order Traversal ************")
|
||||||
in_order(node)
|
in_order(node)
|
||||||
print("\n******************************************\n")
|
print("\n******************************************\n")
|
||||||
|
|
||||||
print("\n********* Post Order Traversal ************")
|
print("\n********* Post Order Traversal ************")
|
||||||
post_order(node)
|
post_order(node)
|
||||||
print("\n******************************************\n")
|
print("\n******************************************\n")
|
||||||
|
|
||||||
print("\n********* Level Order Traversal ************")
|
print("\n********* Level Order Traversal ************")
|
||||||
level_order(node)
|
level_order(node)
|
||||||
print("\n******************************************\n")
|
print("\n******************************************\n")
|
Loading…
Reference in New Issue
Block a user