This is the second part of implementing inorder traversal of a binary tree in Java, in the first part, I have shown you how to solve this problem using recursion and in this part, we'll implement inorder traversal algorithm without recursion. Now, some of you might argue, why use iteration if the recursive solution is so easy to implement? Well, that's true, but the iterative solution is often regarded better as they are not prone to StackOverFlowError. Another reason why we are discussing iterative solution here is because of technical interviews. If you to go to a programmer job interview, you will find that Interviewer will often ask you to solve the same problem using iteration and recursion e.g. Fibonacci series or String reversal algorithm. It's also good for your learning and developing algorithm skill, which is very important for becoming a better programmer.
Read more »