Click here to Skip to main content
15,886,362 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: formulate an algorithm Pin
Gerry Schmitz14-Dec-20 11:37
mveGerry Schmitz14-Dec-20 11:37 
AnswerRe: formulate an algorithm Pin
Patrice T14-Dec-20 12:38
mvePatrice T14-Dec-20 12:38 
AnswerRe: formulate an algorithm Pin
Member 1525570320-Jun-21 20:01
Member 1525570320-Jun-21 20:01 
QuestionProblem in c language Pin
Member 150165689-Dec-20 3:16
Member 150165689-Dec-20 3:16 
AnswerRe: Problem in c language Pin
Richard Deeming9-Dec-20 3:43
mveRichard Deeming9-Dec-20 3:43 
AnswerRe: Problem in c language Pin
CHill609-Dec-20 3:44
mveCHill609-Dec-20 3:44 
AnswerRe: Problem in c language Pin
Serhii Oleksenko15-May-21 1:38
professionalSerhii Oleksenko15-May-21 1:38 
QuestionStamp circular trade Pin
Shir Gans29-Nov-20 6:25
Shir Gans29-Nov-20 6:25 
Hi,

I am building a small web app that allow stamp collectors to swap their stamps. The main problem I am trying to solve is 1-on-1 (direct) swap. Since usually A needs something from B, but B not always need something from A.

But the solution is to find a circular swap, for example:
A needs from B
B needs from C
C needs from A
result: everyone is happy.

I have a list of collectors, and for each a list of stamps they got, and a list of stamp they are looking for.

I am trying to find a way, to create a circle, by matching the "have" and "want". The problem is that this may take a very long time with lots of collectors and lots of stamps Confused | :confused: .

What would be the best approach for this?
The straight forward algorithm I think (which is obviously not optimized) is to:
1) look what "B" want.
2) find who got what B want (stamp after stamp)
3) for each one, see if he (C) needs something from A
4) if yes, YAY
5) if not, see what C want (stamp after stamp)
6) for each one, see if (D) has something from A
... and so on ...

long procedure...

Any suggestions will be very welcome. Thank you
AnswerRe: Stamp circular trade Pin
Gerry Schmitz29-Nov-20 18:40
mveGerry Schmitz29-Nov-20 18:40 
AnswerRe: Stamp circular trade Pin
Mircea Neacsu6-Dec-20 5:45
Mircea Neacsu6-Dec-20 5:45 
GeneralRe: Stamp circular trade Pin
Shir Gans6-Dec-20 7:51
Shir Gans6-Dec-20 7:51 
QuestionGiven an array x, get the array y from a data set of arrays which has the smallest distance to x Pin
Member 1499380315-Nov-20 17:17
Member 1499380315-Nov-20 17:17 
QuestionCLOSED Pin
AlgoHelp13-Nov-20 23:31
AlgoHelp13-Nov-20 23:31 
AnswerRe: How to determine if 2 labelled graphs are identical? Pin
Greg Utas14-Nov-20 1:48
professionalGreg Utas14-Nov-20 1:48 
GeneralRe: How to determine if 2 labelled graphs are identical? Pin
Greg Utas14-Nov-20 3:04
professionalGreg Utas14-Nov-20 3:04 
GeneralCLOSED Pin
AlgoHelp14-Nov-20 3:49
AlgoHelp14-Nov-20 3:49 
GeneralRe: How to determine if 2 labelled graphs are identical? Pin
Greg Utas14-Nov-20 4:03
professionalGreg Utas14-Nov-20 4:03 
GeneralCLOSED Pin
AlgoHelp14-Nov-20 4:24
AlgoHelp14-Nov-20 4:24 
GeneralRe: How to determine if 2 labelled graphs are identical? Pin
Greg Utas14-Nov-20 5:41
professionalGreg Utas14-Nov-20 5:41 
GeneralRe: How to determine if 2 labelled graphs are identical? Pin
Greg Utas15-Nov-20 1:27
professionalGreg Utas15-Nov-20 1:27 
QuestionLong Division / Assembly Language Style Pin
C-P-User-313-Oct-20 4:34
C-P-User-313-Oct-20 4:34 
AnswerRe: Long Division / Assembly Language Style Pin
Richard Deeming13-Oct-20 4:53
mveRichard Deeming13-Oct-20 4:53 
GeneralRe: Long Division / Assembly Language Style Pin
harold aptroot13-Oct-20 5:31
harold aptroot13-Oct-20 5:31 
AnswerRe: Long Division / Assembly Language Style Pin
trønderen13-Oct-20 6:25
trønderen13-Oct-20 6:25 
GeneralRe: Long Division / Assembly Language Style Pin
Greg Utas13-Oct-20 12:04
professionalGreg Utas13-Oct-20 12:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.