Google Interview Question
Java DevelopersCountry: United States
A simple solution is to save in-order tree walk of one of the trees on an array, then run the algorithm on the other trees and compare it with the array. If you do not allowed to use external memory, you should run the in-order tree walk on two trees at the same time. To do this you need to jump from in-order-tree-walk1 to in-order-tree-walk2 whenever a new node is printed in the in-order-tree-walk1 and compare it with the printed node in the in-order-tree-walk2. Inside a for loop do this process for the first tree and all other n-1 trees.
The point of the problem in my opinion is to see if you can manage multiple recursion (A recursion that includes more than one function) or not.
- Anonymous February 14, 2018