1

I took part in a coding contest organized by a club in my college for freshers, In one of the problems it was asked to find out the minimum number of partitions of a number $n$, so that all the integers from $1$ to $n$ can be formed such that the partitions are minimum. For such a problem, I couldn't find anything in searching, and I don't know what to search exactly.

The solution is not satisfactory to me at all, in short, it uses the fact that Strong Induction Proof: Every natural number = sum of distinct powers of 2 and then eerily uses $(7)_{10} = (111)_2$ as an example, saying, from $1, 2, 4$ we can make all integers till $7$, which is true. But this just added more to my confusion.

At the beginning, I got confused with binary representation and since the question on which the answer is based, I couldn't refrain from asking Why not base 3? (I got the answer: because base 3 won't have distinct powers, so it won't be minimum) (1)

Since it is hard to check for even a small test cases, I wrote a program to get more insights, and indeed, minimum number of partitions are the digits in binary representation of $n$, and that the numbers seem arbitrary. Therefore, I think that there might be some link to base $2$, but the way it is being used and explained to me by my peers and seniors might be incorrect.

My approach:

We could use generating function for an arbitrary number of partitions say $k$, (2)

so the generation function would be: $$ (1 + x^{p_1})(1 + x^{p_2})\cdots(1 + x^{p_k}) = 1 + a_1x + a_2x^2+\ldots+a_kx^k$$ where each $p_i$ is the $i^{\text{th}}$ number and $p_1 + p_2 +\ldots+p_k = n$

If we somehow proof that each $a_i > 0$, and then find the minimum condition, we'll be done.

on solving the expression, Differentiation can be hectic, if try to find a pattern by expanding it comes out to be $$ 1 + \sum_{i = 1}^kx^{p_i} + \sum_{i,j = 1}^kx^{p_i + p_j} + \ldots + x^{p_1 + p_2 +\ldots+p_k}$$ ...which doesn't give any lead. And of course, numbers can repeat, which can be even more problematic.

Hence, I'm stuck at the very beginning itself.


My questions are:

  1. There is obviously some link to powers of $2$, but why? and why only $2$?
  2. would my approach (finding a pattern first, then trying to find the minimum condition) actually work?

Some partitions that satisfy the conditions:

$\begin{align} 8 &= 4 + 2 + 1 + 1 \\ &= 3 + 3 + 1 + 1\\ &= 3 + 2 + 2 + 1 \end{align}$

$ \begin{align} 9 &= 5 +2 +1+ 1\\ &=4 +3 +1 +1 \\ &=4+ 2+ 2+ 1\\ &=3 +3+ 2+ 1 \end{align}$

$\begin{align} 14 &= 7+4+2+1 \end{align}$

Note: I know minimum partitions are $\lfloor \log_2(n) \rfloor + 1$, I want to know HOW.

RobPratt
  • 45,619
Sarthak
  • 13
  • 4

1 Answers1

0

Let's say your number $n$ is between $2^{k-1}$ and $2^k-1$.

On one hand, you can make the partition of size $k$. This can be proven by induction on $k$. Namely, $k=1$ means $n=1$, which is its own partition of size $1$. The inductive step (sketch): "halve" $n$, i.e. take $m=\lceil n/2\rceil$, which gives $n-m=\lfloor n/2\rfloor$; prove that $2^{k-2}\le n-m\le 2^{k-1}-1$. Then, partition $n-m$ into a partition with $k-1$ terms (as per inductive hypothesis) and add $m$ to that partition to get a partition of $n$ into $k$ terms. Prove you can now make all the sums from $1$ to $n$.

(This logic can be easily turned into a simple iterative algorirhm, by the way.)

On the other hand, you cannot make a shorter partition. Imagine you had a partition with $l$ terms, where $l\lt k$. How many different sums would you be able to make out of those terms? Each term can be either added to the sum or not, so it is at most $2^l$ sums (some sums may be equal!), however we don't want the "empty" sum (no terms chosen), so in effect you can have at most $2^l-1\le 2^{k-1}-1\lt 2^{k-1}\le n$ sums, i.e. you cannot possibly cover all numbers from $1$ to $n$.

The last part is, for me, providing the intuition for "why powers of $2$?" . Namely, if the number of terms in your partition is too small, you just cannot recreate all the sums you want. The powers of $2$ naturally arise when you try to count the number of different sums you can make, simply because, for every term in your partition, you have exactly two choices: you can either put the term into the sum - or not!

  • I proved the first statement, ("$2^{k-2}\le n-m\le 2^{k-1}-1$"), Then the second step is the inductive step, which is ("Then, partition $n−m$ into a partition with $k−1$ terms (as per inductive hypothesis)"). If this is true, i.e we have all integers from $1$ to $n-m$, adding $m$, it will become $n$ and partitions will increase by $1$ (So, this is the $n = k + 1$ step?). And for rest of the numbers, from $n-m+1$ to $n - m +m$, can be made accordingly as we already have the numbers $1, 2, \ldots, m - 1$. – Sarthak Jan 15 '21 at 06:36
  • I understood why $k$ is the minimum partitions, But if you got the intuition from last step, How did you get the intuition to use the first inequality of n, to begin with? And, can we be sure if the number of sums $2^k$, cover everything from $1$ to $n$? – Sarthak Jan 15 '21 at 06:54
  • I don't quite get the intuition for powers of $2$, yes, powers of $2$ arise when we count the total possible sums... and for minimum, the sums will be more or equal to $n$. but how is this relevant to minimum partitions? Could you please give more insights? – Sarthak Jan 15 '21 at 07:43
  • @Sarthak I am not sure I understand your question. I presumed they call the "minimum" partitions - the shortest partitions, i.e. the ones with fewest terms. If $2^{k-1}\le n\le 2^k-1$, I've proven that you can make a partition of $k$ terms and that no partitions of fewer than $k$ terms would be good. This means that the "minimum" (shortest) partition is of length $k$. Note that, as you have already noticed, the shortest partition is not always unique, the above inductive proof provides you with one potential solution, but there may be others of the same length $k$. –  Jan 15 '21 at 13:14
  • Yes, you have assumed correct, shortest partitions or minimum number of parts, same thing. I understood most of your answer well, but what was your intuition for choosing $2^{k-1}\le n\le 2^k-1$ ? Brilliant proof though.

    I was trying to do the same with other numbers, $3^{k-1}\le n\le 3^k-1$, in this case, I'll be dividing by $3$, So, $m = \lceil n/3 \rceil$ and $n-m = 2\lfloor n/3 \rfloor + 1 $ or $n-m = 2\lfloor n/3 \rfloor$... So, would this work?

    – Sarthak Jan 15 '21 at 20:29