A helpful article in understanding the concept of tree/algorithm and also helpful for interview preparations.

http://bytebeats.com/2011/09/12/comp...here-solution/