this will not solve ..think of node->r->r->l->l
Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Mon, Feb 14, 2011 at 7:50 PM, SEHAJ SINGH KALRA <sehaj...@gmail.com>wrote: > HAD MISSED OUT SOPME THINGS IN PREVIOUS REPLY..... > SORRY GUYS.... > hereby i rectify the mistakes....: > > > > Claim: any given vertical line will start with a node.(This is obvious) > Divide this problem into 2 subparts. > 1st: Finding the starting node of given line. > 2nd : finding the required sum. > > Let T be the tree and L be the given level. > > For 1st part: Find the leftmost node of the given tree,T.This corresponds > to 1st level. > Now let temp=L. > Traverse back from the leftmost tree to its parent(if > T.root is reached then start traversing towards right) > For each traverse decrease temp by 1.Keep on doing this > till temp is not equal to 1. > Call sum_find(temp) > > For 2nd part : int sum=0; > int sum_find(node) > {if (node==null) return 0; > else {sum+= node.data + > sum_find(node.left.right) + sum_find(node.right.left) ) > return sum;} > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.