Try traversing in LEVEL order and maintain array for each level...(Levels
can be found by height of tree)
then try by calculating sums starting from root(level zero) to higher level.
Its typical to explain here but i found it as a solution and that will
definitely found the solution.

On Thu, Jun 30, 2011 at 9:08 AM, rajeev bharshetty <rajeevr...@gmail.com>wrote:

> By traversing tree either preorder or inorder or postorder and storing the
> partial sums along the way and comparing the partial sums with the required
> sum can solve the problem
>
>
> On Wed, Jun 29, 2011 at 7:56 PM, Akshata Sharma <akshatasharm...@gmail.com
> > wrote:
>
>> How to find a path in a given binary tree which sums up to a given target
>> value?
>> for example if the given BT is
>>
>>    5
>>   / \
>>  3   2
>>  /
>> 7
>> and if the target is 10, then the path is ---- root(5) + left node(3) +
>> right node (2).
>>
>> --
>> 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.
>



-- 
**Regards
SAGAR PAREEK
COMPUTER SCIENCE AND ENGINEERING
NIT ALLAHABAD

-- 
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.

Reply via email to