(self, root)
| 31 | self.preOrderRec(root.right) |
| 32 | # inorder without recursion |
| 33 | def inOrder(self, root): |
| 34 | if root == None: |
| 35 | return |
| 36 | pNode, treeStack = root, [] |
| 37 | while pNode or len(treeStack) > 0: |
| 38 | while pNode: |
| 39 | treeStack.append(pNode) |
| 40 | pNode = pNode.left |
| 41 | if len(treeStack) > 0: |
| 42 | pNode = treeStack.pop() |
| 43 | print(pNode.val) |
| 44 | pNode = pNode.right |
| 45 | # inorder with recursion |
| 46 | def inOrderRec(self, root): |
| 47 | if root != None: |