MCPcopy Create free account
hub / github.com/subbarayudu-j/TheAlgorithms-Python / level_order

Function level_order

traversals/binary_tree_traversals.py:75–86  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

73
74
75def level_order(node):
76 if not isinstance(node, TreeNode) or not node:
77 return
78 q = queue.Queue()
79 q.put(node)
80 while not q.empty():
81 node_dequeued = q.get()
82 print(node_dequeued.data, end=" ")
83 if node_dequeued.left:
84 q.put(node_dequeued.left)
85 if node_dequeued.right:
86 q.put(node_dequeued.right)
87
88
89def level_order_actual(node):

Callers 1

Calls 3

putMethod · 0.95
getMethod · 0.95
emptyMethod · 0.45

Tested by

no test coverage detected