algorithm - Divisions of set with even number of elements -
this question has answer here:
- sets of disjoint pairs 2 answers
 
is there effective way list divisions of set {1, ... , 2*n} n pairs?  
the easiest idea list permutations , permutation (a1, a2, ... , a8) means division {{a1,a2}, ... , {a7,a8}}. in situation there 2^n * n! permutations each division. o((2n)!).  
can find more effective way?
here's pencil , paper algorithm:
f(set,result):   if set empty:     return result   otherwise:     pair 1 item set     each of remaining items,     calling f again pair added     result , out of set  123456 12 34 56    35 46    36 45 13 24 56    25 46    26 45 14 23 56    25 36    26 35 ...      
Comments
Post a Comment