Tag Archives: constant space

Inorder traversal using constant space – Morris Traversal

Usual approach using linear space (stack) We can easily do the traversal by using a stack where we keep pushing left. If no left is there then we pop an element to print it and then push its right. This is O(n) time and O(n) space algorithm.   public static void InorderTraversal(BTNode root){ Stack<BTNode> stack […]