Jump to content

Recommended Posts

Posted

Good Time to All, Amici.

 

i got following math problem: to split up number array into two subsets (S1, S2) where X[t] & Y[t] are multiplications of numbers of S1 & S2 respectively, t is index of iteration with condition: |X(0)-Y(0)|==MIN(0), |MIN(0)-(X(1)-Y(1))|==MIN(1), ..., |MIN(n-1)-(X(n)-Y(n))|==MIN(n). for example, let's take an array: 2, 5, 7 then: first pair is {2, 5}, {7} ==> X(0)==2*5==10, Y(0)==7, MIN(0)==3; second is {2, 7}, {5} ==> X(0)==14, Y(0)==5, MIN(1)==6; third is ..

------------------------------------------------

Thanks a lot in Advance.

  • 4 weeks later...
Posted

problem can be rephrased so: [math]\prod_{f\in M}f>x[/math], M is given set, x is given number & [math]\prod_{f\in M}f-x [/math] must have minimal value among possible solutions.

Posted

I haven't got your question, SarK0Y. Is it how to split a given array into two subsets?

Also, what do you mean by MIN(n)? Does it mean the nth minimum product?

Posted
Is it how to split a given array into two subsets?

Also, what do you mean by MIN(n)? Does it mean the nth minimum product?

You're right.


Merged post follows:

Consecutive posts merged

i got idea how to get MIN(0), but other iteration is darkness for me:-(

Posted

Well, I am not an expert in arrays.

 

But, I can say that: Since the difference between successive products is minimum, then you can get the smaller 4 numbers from the array and distribute them on the 2 subsets (4 numbers as 2 for each subset) by calculating the min difference in product. And, then get the following smaller 2 numbers and distribute them on the 2 subsets by making |MIN(0)-(X(1)-Y(1))| a minimum..... and so on.

 

This may work out.

Posted

Amr Morsi, thanks for sharing your idea. i got MIN(0) with following algo:

//(given: set M with n integers)

sort(M); //M(0)<M(1)..<M(n-1)

int x=n-1, y=n-2;

for(int i=n-3; i>-1; i--)

{

if(x>y)y*=M(i);

else x*=M(i);

}

Posted

Amr Morsi, you said about algo for getting of MIN(0)?


Merged post follows:

Consecutive posts merged

hmm.. i did let wrong moment:-)

int x=M(n-1), y=M(n-2);

Posted

For MIN(n), we can have the following algorithm. I think it may also work for MIN(0).

 

//(given: set M with n integers)

sort(M); //M(0)<M(1)..<M(n-1)

ys(0)=M(0); xs(0)=M(1)

for (int L=1; L<(n/2); L+)

{

int x=MIN(2L), y=MIN(2L+1);

if(x>y) ys(L)=M(2L);xs(L)=M(2L+1)

else xs(L)=M(i); ys(L)=M(2L+1)

}

 

This is based upon the procedure I introduced. Feel free to ask any question.

Posted

It is included in "if(x>y)". This compares the MIN Term for each of the 2 new elements, that are under consideration. In other words, it puts element A in S1 and element B in S2 and calculates the MIN Term (int x=MIN(2L)), then make the opposite and recalculate the MIN Term again (y=MIN(2L+1)). The correct classification is the one that gives the least MIN Term.

 

Note: xs is S1 and ys is S2.

 

Is it clear?

Posted

Amr Morsi, i got your idea, my friend, but we have collision: MIN(i)==MIN(j) with (j==i)==false & j==i.

Posted

This is included in the "else" statement. And, with respect to logic: It doesn't differ in that case which element will go to which set.

Posted

Amr Morsi, we can use a little one idea: MIN(0)'s generating gives a vector of number's distribution between S1 & S2 to us, this vector can be converted to usual integer Map, so Map=Map-1 is vector to get MIN(1), Map-2 is vector to get MIN(2),.. , Map-i is vector to get MIN(i).

Posted

Amr Morsi, here isn't difference. if you want to see idea, let's observe example: take {11, 7, 2}, vector for MIN(0) is 100b (|7*2-11|=3), MIN(1) is 011b [math]\rightarrow[/math]3, MIN(2) is 010b [math]\rightarrow[/math]22-7=17, MIN(3) is 001b [math]\rightarrow[/math]77-2=75.

Posted

Do you mean to find MIN for all possible arrangements of the main array? But, this is not the definition for MIN(n). In addition, you are exchanging elements between the two sets. Are you going to compare MINs to find the two sets?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.