Algorithm for dividing a set of numbers into groups

In summary, the algorithm for dividing a set of numbers into groups involves first determining the total number of groups desired and then evenly distributing the numbers among those groups. If there are any remaining numbers, they are added to the last group. This method ensures that each group has a similar number of elements and can be useful for tasks such as data analysis and organizing data in a logical manner.
  • #1
jorgendt
1
0
I'm looking for an algorithm for dividing a set of numbers into groups, and then doing it again in such a way that no numbers are in a group together more than once.

For instance if you have 18 numbers and divide them into groups of three you should be able to do this 8 times without any numbers having to be in the same group more than once. Any idea how I can do this?

This website: http://mathpages.com/home/kmath388.htm
kinda describes what I'm looking for, but I don't quite get the hang of how they do it, when I try to do something similar with other numbers I end up with repeats (I try to replicate the part where they divide 24 people into four-man-groups in seven different ways).

Thanks in advance for any help. :)
 
Physics news on Phys.org
  • #2
Firstly it is useful to count how many ways this can be done. There is a function which does this called the multinomial coefficient (generalization of the binomial coefficient).

If you wish to divide a set of N objects into groups of size [itex]n_1, n_2,\cdots , n_k[/itex] where these [itex]n[/itex]'s add up to big N, the number of ways is:
[tex] \frac{N!}{n_1 !\cdot n_2 ! \cdot \ldots \cdot n_k!},\quad \text{where}\quad n!=n(n-1)(n-2)\cdots 1[/tex]
(i.e. 5! = (5)(4)(3)(2)(1) = 120.)

So the number of ways to divide 18 objectsinto 6 specific partitions of 3 each is...
[tex]\frac{18!}{3!\cdot 3! \cdot 3! \cdot 3! \cdot 3! \cdot 3! }=...
\frac{18\cdot 17 \cdot 16 \cdot 15\cdot 14\cdot 13 \cdot 12\cdot 11\cdot 10 \cdot 9 \cdot 8\cdot 7\cdot 6 \cdot 5 \cdot 4 \cdot 3 \cdot 2 \cdot 1}{6\cdot 6\cdot 6 \cdot 6\cdot 6\cdot 6}
=\ldots = 137,225,088,000[/tex]
That's if each of the 6 groups of 3 has different meaning. If however you simply want to figure ways to divide them up into sets of a given size you need to divide by the number of ways to rearrange partitions of a given size. In the above example there are 6 sets of size 3 so you divide by 6! (six factorial = 720) to get 190,590,400.

Now counting is good, but if you need an algorithm to enumerate every case then that's tough especially if you want to be sure to get every case but not repeat any equivalent cases. If you simply want to picke one arrangement at random then put all elements in a list, shuffle the list thoroughly and pick the first [itex]n_1[/itex] of that list, the next [itex]n_2[/itex] of that list, ... and so on.
 
  • #3
There is no generalised algorithm as that page (and others on this problem such as this one and http://www.maa.org/editorial/mathgames/mathgames_08_14_07.html) hint at.

If you can't use the already-generated solutions on those pages you are going to need to build some method of spanning possible combinations either with brute force or some evaluation/backtracking algorithm.
 

1. What is an algorithm for dividing a set of numbers into groups?

An algorithm for dividing a set of numbers into groups is a step-by-step process or set of rules that determines how to split a given set of numbers into smaller groups based on certain criteria.

2. How does the algorithm determine the number of groups to divide the numbers into?

The algorithm uses the total number of numbers in the set and the desired size of each group to determine the number of groups. It divides the total number of numbers by the desired size and rounds up to the nearest whole number to determine the number of groups.

3. What criteria can be used to divide the numbers into groups?

The criteria used to divide the numbers into groups can vary depending on the specific algorithm. Some common criteria include the value of the numbers, the parity (odd or even), or the frequency of occurrence of certain numbers in the set.

4. Can the algorithm handle sets with a large number of numbers?

Yes, the algorithm can handle sets with a large number of numbers. However, the time and resources required to execute the algorithm may increase as the size of the set increases.

5. Are there any limitations to the algorithm for dividing a set of numbers into groups?

Like any algorithm, there may be limitations depending on the specific implementation. Some common limitations include the type of numbers that can be divided (e.g. only positive integers), the maximum number of groups that can be created, or the accuracy and efficiency of the grouping process.

Similar threads

  • Set Theory, Logic, Probability, Statistics
Replies
2
Views
554
  • Set Theory, Logic, Probability, Statistics
Replies
4
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
5
Views
2K
  • Linear and Abstract Algebra
Replies
10
Views
335
  • Set Theory, Logic, Probability, Statistics
Replies
3
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
11
Views
475
  • Set Theory, Logic, Probability, Statistics
Replies
2
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
7
Views
306
  • Set Theory, Logic, Probability, Statistics
Replies
4
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
4
Views
373
Back
Top