a DFS on the tree to set up : * arrays for parent , depth , subtree size for every node ; * deeper end of every Edge
dfs ( root , parent_of_root , depth_of_root , n ) ; int [ ] chain_heads = new int [ N ] ;