@@ -0,0 +1,988 @@
+package com.sunny.grokkingalgorithms.fasttrack.dynamicprogrammingandrecursion;%0A%0Aimport com.sunny.grokkingalgorithms.ctci.c4.util.BinaryTreeNode;%0Aimport com.sunny.grokkingalgorithms.ctci.c4.util.TreeUtils;%0A%0A/**%0A * Created by sundas on 6/12/2018.%0A */%0Apublic class AddSumTotalOfHeirarchyForGiveBinaryTree %7B%0A%0A   /*%0A   Given a binary tree add the sum of all its nodes in the child hierarchy%0A   to the node%0A    */%0A%0A  public static int addHierarchySumToAllNodes(BinaryTreeNode root)%7B%0A    if(root == null)%7B%0A      return 0;%0A    %7D%0A    int leftSum = addHierarchySumToAllNodes(root.left);%0A    int rightSum = addHierarchySumToAllNodes(root.right);%0A    root.data += leftSum + rightSum;%0A    return root.data;%0A  %7D%0A%0A  /**%0A   *%0A   * @param args%0A   */%0A  public static void main(String%5B%5D args) %7B%0A    BinaryTreeNode root = TreeUtils.createBST();%0A    TreeUtils.performBfsLevelMarker(root);%0A    System.out.println(%22#####%22);%0A    addHierarchySumToAllNodes(root);%0A    TreeUtils.performBfsLevelMarker(root);%0A  %7D%0A%0A%7D%0A

Add sum of nodes to root's hierarchy binary tree probblem.