Re: [algogeeks] Re: Finding Minimum Triplet
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 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 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 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, >> > 10it60...@iitkgp.ac.in >> >> -- >> 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 Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in -- 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.
Re: [algogeeks] Re: Finding Minimum Triplet
@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 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 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, > > 10it60...@iitkgp.ac.in > > -- > 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.
Re: [algogeeks] Re: Finding Minimum Triplet
Thanku sir... On 29 November 2011 10:20, Dave 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 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, > > 10it60...@iitkgp.ac.in > > -- > 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 Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in -- 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.
[algogeeks] Re: Finding Minimum Triplet
@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 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, > 10it60...@iitkgp.ac.in -- 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.