Re: Looking for an algorithm to accomplish the following
- From: "Jaco van Niekerk" <sparky@xxxxxxxxxx>
- Date: Wed, 31 Aug 2005 09:18:44 +0200
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
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?
Let me know and I'll see what I can do. What language are you using? C?
"fadi" <fadi@xxxxxxxxxx> wrote in message
news:ZA5Re.202525$0f.63775@xxxxxxxxxxxxxxxxxxxxxxx
> Hello all,
>
> Lets say there are N number of sets and each set has the same number of
> attributes as follows:
>
> Set1: W=10, X=15, Y=5, Z=25
> Set2: W=10, X=5, Y=10, Z=20
> Set3: W=10, X=10, Y=20, Z=0
> Set4: W=10, X=30, Y=10, Z=5
>
> Now, to find the sets that if summed, you would get the following values:
>
> Result: W= 20, X=15, Y=30, Z=20
>
> Answer would be Set2 + Set3 of course, but is there an algorithm that I
> can follow that would find this answer for me?
>
> It is really more complicated than this where the desired Result can be
> off by certain factor and would have condition as to which can be
> added..etc, but an algorithm would be a starting point for a software I am
> writing hopefully.
>
> Thanks!
>
.
- Follow-Ups:
- References:
- Prev by Date: Re: How Were Those Tables Computed?
- Next by Date: Matrixproduct or scalar multiplied with matrix?
- Previous by thread: Re: Looking for an algorithm to accomplish the following
- Next by thread: Re: Looking for an algorithm to accomplish the following
- Index(es):
Relevant Pages
|
|