Re: Looking for an algorithm to accomplish the following



"Jaco van Niekerk" <sparky@xxxxxxxxxx> wrote in message
news:df3lkm$mf$1@xxxxxxxxxxxxxxxxxxxxx
> Hi Fadi
>
> I have some questions. Firstly are the set's as nicely behaved as
> depicted below? For your sets, say S1 and S2, you could simply go Sum =
> S1[I] + S2[I]. Are the entries to be added always in the same position?
> or could it as follows:
>
> Set2: W=5, X=10, Y=10, Z=20
> Set3: W=10, X=0, Y=20, Z=10
>
> Now result is W=20, X=15, Y=30, Z=20, because
>
> Result.W = Set2.X + Set3.Y = 20
> Result.X = Set2.W + Set3.W = 15
> Result.Y = Set2.Z + Set3.Z = 30
> Result.Z = Set2.Y + Set3.X

The items will always be in same position that is correct.




> Secondly, if your sets are behaved it seems like your solution is going to
> be O(n^2). I guess you could use hashing to cut down on the time, but
> that depends on how large your sets are. Are they all 4 elements in size?
> How many are there in total? 10 sets? 1000 sets? Also do you only add 2
> sets at a time? Or could we add up set 2, 5 and 7 to get your result?

More than 2 sets can be added as long as the total is reached, and each set
can be used more than once.




> Let me know and I'll see what I can do. What language are you using? C?

I will be using C#, I could do it in C, but I need to integrate it into
existing application written in C#.


.



Relevant Pages


Loading