MCPcopy Index your code
hub / github.com/BeeBombshell/Python-DSA / inorderTraversal

Method inorderTraversal

Tree Data Structure/inorder_traversal.py:28–42  ·  view source on GitHub ↗
(self, root)

Source from the content-addressed store, hash-verified

26 return Tree
27class Solution(object):
28 def inorderTraversal(self, root):
29 res, stack = [], []
30 current = root
31 while True:
32 while current:
33 stack.append(current)
34 current = current.left
35 if len(stack) == 0:
36 return res
37 node = stack[-1]
38 stack.pop(len(stack)-1)
39 if node.data != None:
40 res.append(node.data)
41 current = node.right
42 return res
43ob1 = Solution()
44root = make_tree([10,5,15,2,7,None,20])
45print(ob1.inorderTraversal(root))

Callers 1

Calls 2

appendMethod · 0.80
popMethod · 0.80

Tested by

no test coverage detected