Given above binary tree output should be sum of all nodes , that is:
9+6+12+5+7+10 = 49

Process: 

  • Here first of all we will ask root node (9), what is the sum of nodes of your tress . We will receive answer as  : my sum + my left sub-tree sum +my right sub-tree sum
  • Similarly flow will goes down


Post a Comment

Previous Post Next Post