he distance of a triplet (a,b,c) is defined is *max*(|a-b|, |b-c|, |c-a|) is the correct one...
On 29 November 2011 11:09, atul anand <[email protected]> wrote: > @Raja : distance is defined as > > The distance of a triplet (a,b,c) is defined is *max*(|a-b|, |b-c|, |c-a|) > > OR > > The distance of a triplet (a,b,c) is defined is *min*(|a-b|, |b-c|, |c-a|) > > > On Tue, Nov 29, 2011 at 11:50 PM, Dave <[email protected]> wrote: > >> @Kumar: Let the three arrays be a, b, and c, of lengths na, nb, and >> nc, respectively. >> Sort each array. >> Set ia = 0, ib = 0, ic = 0. >> Record the triplet (a[0], b[0], c[0]) as the best so far. >> Loop >> Increment the index corresponding to the smaller of a[ia], b[ib], >> and c[ic]. >> If the incremented index reaches its corresponding length, break >> the loop. >> If the new (a[ia], b[ib], c[ic]) is better than the best so far, >> update the best so far. >> End loop >> >> O(n log n), where n = max(na,nb,nc). >> >> Dave >> >> On Nov 29, 11:42 am, kumar raja <[email protected]> wrote: >> > Given three arrays, find the triplet (containing one element from each >> > array) with the minimum >> > distance. The distance of a triplet (a,b,c) is defined is max(|a-b|, >> |b-c|, >> > |c-a|) >> > >> > -- >> > Regards >> > Kumar Raja >> > M.Tech(SIT) >> > IIT Kharagpur, >> > [email protected] >> >> -- >> 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. >> >> > -- > 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. > -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, [email protected] -- 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.
