Re: [algogeeks] Re: Divide an array into two equal subsets

2011-01-04 Thread ADITYA KUMAR
@ sunny is there any reason for splitting the array in ur manner ?? and what abt the complexity ?? i think each time u exchange b/w A and B it takes O(n*n) so u have complexity O(no_of_exchanges*n*n) O(n^2) solution sort the array...O(nlogn) S=total sum search for that continous su

Re: [algogeeks] Re: Divide an array into two equal subsets

2011-01-04 Thread Ankur Khurana
there is some problem , i mean you taken some assumptions here. in first caes 1 and 4 have difference of 3 which is not less than 2 , am i missing something. also , if we have two replacement values , which will we replace , i mean excahnge if there are two chocies . I think your algo might work wi

[algogeeks] Re: Divide an array into two equal subsets

2011-01-04 Thread sunny
How about this algorithm: 1 sort the given array in ascending order 2 traverse from back that is greater to smaller 3 put the 1st read in arrayA and the 2nd read in arrayB 4 put the 3rd read in arrayB and the 4th read in arrayA (notice we have reverse the order of putting the values) 5 repeat the

[algogeeks] Re: Divide an array into two equal subsets

2010-12-29 Thread suhash
Your solution does not consider the fact that the two subsets have equal elements(50 elements each) You have provided a solution for http://www.spoj.pl/problems/FCANDY/ But this question is different. It is similar to http://www.codechef.com/problems/TEAMSEL/ On Dec 29, 10:56 pm, vishal raja wro