Finding pattern, grouping all possible pairs of first N natural number , with certain condition

129 Views Asked by At

I may not be able explain the question , but you can easily understand by example ,

Given all pairs of first N natural numbers ( order doesn't matter ) , N is even, the condition is to create groups of pairs, such that each group is mutually exculsive and exhaustive,( all N elements are used inside a group and no element is used again) Also , a pair once used is not used again in any group.

obviously, each group has size N/2 and there are N-1 groups in total.

Eg,

given N = 4, total pairs = 4c2 = 6 , groupsize = N/2 = 2, total groups = N-1 = 3 
possible pairings :
1st group : (1,2) , (3,4)
2nd group : (1,3) , (2,4)
3rd group : (1,4) , (2,3)

given N = 6, total pairs = 6c2 = 15 , groupsize = N/2 = 3, total groups = N-1 = 5 
possible pairings :
1st group : (1,2) , (3,4) , (5,6)
2nd group : (1,3) , (2,5) , (4,6)
3rd group : (1,4) , (2,6) , (3,5)
4th group : (1,5) , (2,4) , (3,6)
5th group : (1,6) , (2,3) , (4,5)

The problem is that I can do this by hit and trial method , but for large values of n I might not be able to find a pattern for grouping easily. Just as a side note I am also interested in how many ways I can do this grouping. Can anyone help me with this ?

Thanks in advance!

1

There are 1 best solutions below

1
On BEST ANSWER

This is equivalent to a round-robin tournament, for which there is a standard scheduling algorithm: Imagine the numbers sitting in opposite pairs at a long table; fix one of them (say, the $1$) and for each group rotate the others around the table. Thus, in group $k$ with $1\le k\lt N$, the $1$ is paired with $k+1$ and otherwise $(i,j)$ are paired if $i+j\equiv2k\bmod N-1$.