dynamic programming and few other tree problems