Monday, May 1, 2017

Basic Dp On Tree

   

 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

       


  1. Determine the bottom nodes of the tree (with no children)
  2. Assign "weight" 1 to each of the bottom nodes
  3. Build your way up the tree calculating the "weight" of each node (for example a node with 2 children has "weight" 3)
  4. That's your answer....

    Related Problem:
     Even-Tree

                Cut The Tree

1 comment:

  1. Pragmatic Play brings US online slot machines to NJ - KTNH
    The partnership 대전광역 출장샵 will 춘천 출장샵 see Pragmatic 원주 출장마사지 Play bring a 당진 출장샵 suite of online slot machines to to the state of New Jersey, 용인 출장마사지 according to a release from

    ReplyDelete

Football Player Transfer Prediction

Football Player Transfer Prediction Using Different Classifiers Project Report :  Football Player Transfer Prediction Report ...