@ vishal :let array be {5,2,1,1} ==> as per u'r algo =>{1,2},{1,5} are sets
difference is 3 .. but the sol is {5}{1,1,2} ==> diff = 1;On Fri, Nov 16, 2012 at 10:12 AM, vishal chaudhary <[email protected] > wrote: > Hi > Sorry for that as i misinterpreted the question. > for the difference to be minimum, i think(not completely sure) we can > first sort the array > and then we can start putting the elements at even index in the last part > of the array and the odd ones in the starting in the new array > you can do this in the same array itself i guess but you have to do some > kind of shifting. > by doing this for all the elements and dividing them into two groups. > I hope this helps. > > Vishal > > > > On Fri, Nov 16, 2012 at 9:46 AM, bharat b <[email protected]>wrote: > >> @ vishal : how can u divide an array into 2 groups whose difference is >> maximum in O(1). why max? >> >> solution : http://www.youtube.com/watch?v=GdnpQY2j064 >> >> >> >> >> On Fri, Nov 16, 2012 at 9:22 AM, vishal chaudhary < >> [email protected]> wrote: >> >>> Hi >>> you can first sort the array which can be done in O(nlogn) complexity if >>> the number of items in the array is n. >>> Then using the indexing of arrays you can divide the array into two >>> groups whose difference is going to be maximum and this can be done in O(1) >>> complexity. >>> So the complete algorithm is going to take O(nlogn) complexity. >>> Kindly share an alternative algorithm if you find one with lower >>> complexity. >>> >>> Vishal >>> >>> >>> On Wed, Nov 7, 2012 at 7:43 PM, Arun Kindra <[email protected] >>> > wrote: >>> >>>> Given an unsorted array, how to divide them into two equal arrays whose >>>> difference of sum is minimum. >>>> >>>> -- >>>> 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. >>> >> >> -- >> 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. > -- 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.
