Balanced Binary Tree T ree problems are quite popular among competitive programming questions. A ll the fame is because of the co mplexity of thought they deliver to the mind of a beginner and sometimes they even scare the intermediate programmers, who have been programming for a while. Here in this blog, I will discuss a general problem that has similar complexity issues and share a thought to break the solution. Some Prerequisites Sites all over the internet are filled with basic level tree problems like Finding the depth of a node in a tree Finding the height of a tree Sum of a subtree rooted at some internal node of the tree Finding LCA (Lowest Common Ancestor)of two nodes of a tree (in O(N)) Finding LCA of any two nodes of a tree (in O(logN)) Generally speaking, all such problems are the building block for the tree-problems of intermediate level, like one discussed below. A Generic Problem The problem starts with a description of a tree and clearing out what all kind of...
This is where I write all my thoughts