@ankit: ur space complexity will be too high. i think it will be ultimately 2^n where n is the number of the nodes.
On Wed, Jun 29, 2011 at 1:10 PM, ankit sambyal <ankitsamb...@gmail.com>wrote: > The idea is to traverse the binary tree in post order and find out all > the path sums and store them. Use a hashtable or any other data > structure to store the possible paths rooted at a node and going > down-only. Now we can construct all paths going through a node from > itself and its childrens' paths. > > If the idea is not clear, I will post the detailed algo.. > > > > > On Wed, Jun 29, 2011 at 9:16 AM, Akshata Sharma > <akshatasharm...@gmail.com> wrote: > > ya..there can be other paths, like the on you mentioned.. > > > > On Wed, Jun 29, 2011 at 9:25 PM, Piyush Sinha <ecstasy.piy...@gmail.com> > > wrote: > >> > >> 7+3 also give the sum to be 10??? > >> > >> On 6/29/11, 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. > >> > > >> > > >> > >> > >> -- > >> *Piyush Sinha* > >> *IIIT, Allahabad* > >> *+91-8792136657* > >> *+91-7483122727* > >> *https://www.facebook.com/profile.php?id=100000655377926 * > >> > >> -- > >> 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. > > > > -- > 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. > > -- Varun Pahwa B.Tech (IT) 7th Sem. Indian Institute of Information Technology Allahabad. Ph : 09793899112 ,08011820777 Official Email :: rit2008...@iiita.ac.in Another Email :: varunpahwa.ii...@gmail.com People who fail to plan are those who plan to fail. -- 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.