algorithm - Random Pairings that don't Repeat -


This small project / problem came out of the left field for me, hoping someone can help me here. I have some rough ideas but I am sure (or at least I hope) a simple, quite efficient solution exists.

Thanks in advance ... the phony code is okay. I usually work in .net / C # if any solution is highlighted on your solution.

Given:

The pool of people who will be found on regular basis. I need to make pairs that are not available before. The pool of individuals will gradually change over time. For the purpose of coupling, (A & B) and (B & A) constitute the same pair, the history of the previous pair has maintained. For the purpose of the problem, assume any number of individuals, each meeting (collection of pairs) and the person will be added only once.

Is there an algorithm that will allow us to make these pairs? Ideally, by sorting the joints in a random order, doing something better and then checking against the history of the previous couple is something better. In general, randomness within the partner is fine.

A little more:

I can understand a number of ways to create a random pool, so that people can jointly check against the history of those people and either pool them Back in or remove them and add them to the list of coupled individuals. I can not get around my head that at some point I will be left with a list of people who can not be added but ... some of those people may be possibly linked with those coupled list Are in I can return one of those partners to the pool of unexpected members, but it seems that it would be difficult to test a loop, which would be difficult to test and could run forever.

  • History in a structure with o (1) Load "Includes" test such as
  • Loop every 0.5 * n * (n-1) through possible pinning
    • Check if this is in pairing history
    • If not, continue the repetition of the next loop
    • Increase the "number found" counter
    • Incidentally, coupling as a "result" If you have an answer for "result" then use it, otherwise all possibilities are terminated
  • P> It will run in O (N ^ 2) + O (history size), and will expose the case thoroughly when all possibilities are terminated.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -