[algogeeks] Re: Interview question amazon
Not clear what path you are referring to. Question. Should the path include root value always? (What is problem with only left or only right path (not containing root)) In your example for 16 one more path can be 0 1 5 10 as well. Should algo return all the paths or just first one. On Dec 26, 10:08 pm, MAC wrote: > you are given a bst where each node has a int value , parent pointer , and > left and right pointers , write a function to find a path with a given sum > value. Path can go from left subtree tree , include root and go to right > tree as well . we need to find these paths also . > > 5 > 1 10 > 0 2 6 11 > > so to find 16 we say it is 1 to 5 to 10 > > -- > thanks > --mac -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@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.
[algogeeks] Re: DIVIDE TWO VARYING LENGTH NUMBERS.
The better option will be to shift and divide. As you can store the arbitrary large number in a link list or int array. Left shift the right array and subtract, this will give you a better approach, rathar than just subtracting each time. Add them in the end .. On Dec 27, 1:47 am, Aniket wrote: > DIVIDE TWO VARYING LENGTH NUMBERS > EX: ONE CAN BE UPTO 60 DIGIT AND OTHER 40 DIGIT > > Well,I thought of an approach.Store each digit of each number in two > separate integer arrays(From right to left).Then apply the subtraction > method.Will it be feasible? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@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.
[algogeeks] Re: Find all the subset of an array whose sum is equal to some number
Thanks , I need to learn sml now :). I was looking for the conversation over algo development and hints to do that. On Dec 25, 10:04 pm, Puneet Ginoria wrote: > This attachment contains the code for the above program in SML language and > it uses lambda calculus. > > > > > > > > On Sat, Dec 25, 2010 at 9:18 PM, juver++ wrote: > > What you need to get for the answer - amount of such subsets or display > > them? > > First problem can be solved using DP. > > Second - brute force. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Algorithm Geeks" group. > > To post to this group, send email to algoge...@googlegroups.com. > > To unsubscribe from this group, send email to > > algogeeks+unsubscr...@googlegroups.com > .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 algoge...@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.
[algogeeks] Re: Find all the subset of an array whose sum is equal to some number
On what basis we will divide the array. (Eg 1. Sort and divide them on positive negative ) On Dec 25, 10:52 pm, radha krishnan wrote: > This s similar to the problemhttps://www.spoj.pl/problems/SUBSUMS/ > we have to split the array into 2 arrays > say A,B > generate all subsets of each array(both A and B) and another > array(A1,B1) to store the sum of each subset > now take each element of A1 and binarysearch B1 to achieve this sum > assume k=2^(n/2) > overall complexity is (2*(2^(n/2)) + 2*(k(lgk)) +k lgk) > 2^(n/2) for each subset so 2*(2^(n/2)) > k(lg k) -- sorting so 2*(k lg k) > k(lgk)--binary search > > On Sat, Dec 25, 2010 at 10:38 PM, Puneet Ginoria > > > > > > > > wrote: > > sorry i forgot to attach here it is > > > On Sat, Dec 25, 2010 at 10:34 PM, Puneet Ginoria > > wrote: > > >> This attachment contains the code for the above program in SML language > >> and it uses lambda calculus. > > >> On Sat, Dec 25, 2010 at 9:18 PM, juver++ wrote: > > >>> What you need to get for the answer - amount of such subsets or display > >>> them? > >>> First problem can be solved using DP. > >>> Second - brute force. > > >>> -- > >>> You received this message because you are subscribed to the Google Groups > >>> "Algorithm Geeks" group. > >>> To post to this group, send email to algoge...@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 algoge...@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 algoge...@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.
[algogeeks] Re: Find all the subset of an array whose sum is equal to some number
Well All the subsets, not the number On Dec 25, 8:48 pm, juver++ wrote: > What you need to get for the answer - amount of such subsets or display > them? > First problem can be solved using DP. > Second - brute force. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@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.
[algogeeks] Find all the subset of an array whose sum is equal to some number
Given an unsorted array of integer containing positive and negative number both. We Need to find out all the subsets (including non-contiguous subset) of the array, whose sum is equal to a given number. -Rohit -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@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.