From 4bd889af2ed0999410f8aa25d438d08bf02146ba Mon Sep 17 00:00:00 2001 From: kishore-tw Date: Fri, 14 Oct 2022 09:03:01 +0530 Subject: [PATCH] Add in order traversal for binary tree in python --- Binary Trees/python/in_order_traversal.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Binary Trees/python/in_order_traversal.py b/Binary Trees/python/in_order_traversal.py index e69de29..1db4f4a 100644 --- a/Binary Trees/python/in_order_traversal.py +++ b/Binary Trees/python/in_order_traversal.py @@ -0,0 +1,11 @@ +class Solution: + def __init__(self): + self.arr = [] + + def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]: + if root: + self.inorderTraversal(root.left) + self.arr.append(root.val) + print(root.val) + self.inorderTraversal(root.right) + return self.arr \ No newline at end of file