Partition set to contain the same number of elements distributing the remainder

136 Views Asked by At

Given $|B| = 23$ and number of partitions $P=4$. We want to partition the given set $B = B_1\cup\dots\cup B_P$ so that every partition $B_i$ contains the same amount of elements where the remaining elements are assigned to $B_1, \dots, B_P$.

At the beginning every partition gets an entire number of elements:

$\lfloor|B| / P\rfloor = 5$

$|B|- \lfloor|B| / P\rfloor * P = 3$

And the remaining elements are distributed as follows

$|B_1| = 5 + \textbf{1}$

$|B_2| = 5 + \textbf{1}$

$|B_3| = 5 + \textbf{1}$

$|B_4| = 5 + \textbf{0}$

How can we calculate from the given information the remaining number of elements (Bold in the partitions)?

1

There are 1 best solutions below

0
On

Now I have the answer. The number of elements in the partitions can be calculated using the following formula:

$|B_p| = \lfloor|B| / P\rfloor + sgn(\lfloor(|B| - \lfloor|B|/P\rfloor P)/p\rfloor)$

Example from above:

$|B_1| = \lfloor23 / 4\rfloor + sgn(\lfloor(23 - \lfloor23/4\rfloor 4)/1\rfloor)$

$|B_1| = 5 + 1$