@tushar thnxx for correction :D
On Mon, Feb 14, 2011 at 7:50 PM, SEHAJ SINGH KALRA <[email protected]>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 [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
With Regards,
*Jalaj Jaiswal* (+919019947895)
Software developer, Cisco Systems
B.Tech IIIT ALLAHABAD
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.