Problem:
Given a tree with n nodes we have to find the number of nodes under each sub-tree
The root is 1.
Solution:
we can solve this with dynamic programming
- Determine the bottom nodes of the tree (with no children)
- Assign "weight" 1 to each of the bottom nodes
- Build your way up the tree calculating the "weight" of each node (for example a node with 2 children has "weight" 3)
- That's your answer....
Related Problem:
Pragmatic Play brings US online slot machines to NJ - KTNH
ReplyDeleteThe partnership 대전광역 출장샵 will 춘천 출장샵 see Pragmatic 원주 출장마사지 Play bring a 당진 출장샵 suite of online slot machines to to the state of New Jersey, 용인 출장마사지 according to a release from