Sometimes I come across interview questions such as this : "Find the common parent of any two nodes in the tree." I noticed that they are asking LCA questions also on Google, Amazon, etc.
As wikipedia says, an LCA can be found by crossing paths from given nodes to the root and takes O (H), where H is the height of the tree. In addition, there are more complex algorithms that process trees in O (N) and respond to LCA requests in O (1).
Interestingly, it is the interviewers who want to know about the candidates asking this question by the LCA. The first path crossing algorithm seems trivial. Do they expect candidates to remember preprocessing algorithms? Do they expect candidates to invent these algorithms and data structures on the fly?
source
share