@jalaj Tree may have negative values. Anurag Sharma
On Fri, Jun 25, 2010 at 7:38 PM, jalaj jaiswal <[email protected]>wrote: > first do a traversal of the tree and find the maximum value.... > now take an auxilarry aray a[MAX].. initialize this array to zero > > now traverse the tree and each time update the value in array > a[valueintree]++; > and keep a check,if the value is 2.if at any time any value is 2 after > incrementing ...the index of array is the duplicate value in tree > > total time O(n)... > > but this method had space constraint... any one better ?? > > On Fri, Jun 25, 2010 at 5:34 PM, RIDER <[email protected]> wrote: > >> you are given a binary tree (not a BST) .how to find is there is any >> element which occurs twice and if so what is value ? >> >> -- >> 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]<algogeeks%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> >> > > > -- > With Regards, > Jalaj Jaiswal > +919026283397 > B.TECH IT > 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]<algogeeks%[email protected]> > . > 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 [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.
