I was given a task of trying to print the postorder traversal of a binary tree when you are given the preorder and the inorder traversals.
I went online to search up the problem, but the only results that I found was this GeekForGeeks article. However, I found this article quite confusing and I didn't understand how to solve this problem even after reading the article. Can someone help simplify the article into simpler words? Thanks!
This is impossible in the general case. Consider:
Let's label these as
Now consider:
Given preorder and inorder trees as AAB will not have an unambigous postorder representation.