1 Introduction

For a Young diagram \(\Lambda \), let \(n=|\Lambda |\) be the number of cells, let \(\lambda \vdash n\) be the partition of n whose i-th part \(\lambda _i\) is the number of cells in the i-th row, and let \(\lambda ^*\vdash n\) be the conjugate partition of n whose j-th part \(\lambda ^*_j\) is the number of cells in the j-th column, so that \(\lambda ^*_j=|\{i:\lambda _i\ge j\}|\). For function \(f:[n]\rightarrow \mathbb {Z}\) let \(f(\lambda )=\sum _i f(\lambda _i)\) be the sum of evaluations of f on the parts of \(\lambda \). See [1] for more information on Young diagrams and partitions and their many applications.

We consider here the following algorithmic problem.

Optimization over Young diagrams Given n and functions \(f,f^*:[n]\rightarrow \mathbb {Z}\), find a Young diagram \(\Lambda \) which minimizes \(f(\lambda )+f^*(\lambda ^*)\). Equivalently, solve \(\min \{f(\lambda )+f^*(\lambda ^*)\,:\,\lambda \vdash n\}\).

Example 1.1

Let \(n=6\) and \(f(k)=f^*(k)=k^2\). Then, there are 11 Young diagrams \(\Lambda \) with

$$\begin{aligned} \lambda= & {} (6),\ (5,1),\ (4,2),\ (4,1^2),\ (3^2),\ (3,2,1),\ (3,1^3),\ (2^3),\ (2^2,1^2),\ (2,1^4),\ (1^6), \\ \lambda ^*= & {} (1^6),\ (2,1^4),\ (2^2,1^2),\ (3,1^3),\ (2^3),\ (3,2,1),\ (4,1^2),\ (3^2),\ (4,2),\ (5,1),\ (6). \end{aligned}$$

Computing the objective function \(f(\lambda )+f^*(\lambda ^*)\) exhaustively for all, we find that the unique optimal one is the self-conjugate \(\lambda =\lambda ^*=(3,2,1)\) with value \((3^2+2^2+1^2)+(3^2+2^2+1^2)=28\).

The number of Young diagrams is exponential in n and so solution by exhaustive search in general is prohibitive. Nonetheless, we show that the problem is polynomial time solvable.

Theorem 1.2

Optimization over Young diagrams can be done in time polynomial in n.

2 Proof

We begin with a construction of Young diagrams which will be necessary for our purposes. The type of a Young diagram \(\Lambda \) and of the associated partition \(\lambda \) is the number of distinct parts of \(\lambda \). It is easy to see that \(\lambda \) and \(\lambda ^*\) have the same type which, assuming that the diagram is drawn according to the English convention, is equal to the number of “southeast corners” of \(\Lambda \). If \(|\Lambda |=n\) and \(\Lambda \) has type k so \(\lambda =(r_1^{c_1},\ldots ,r_k^{c_k})\) for some \(r_1>\cdots >r_k\ge 1\) and some \(c_1,\ldots ,c_k\ge 1\), then \(n=\sum _{i=1}^kc_ir_i\ge \sum _{i=1}^k i\) so \(k<\sqrt{2n}\). For instance, \(\lambda =(19,\ldots ,2,1^{11})\) is a partition of \(n=200\) of maximum type \(k=19<20=\sqrt{2n}\).

Let \(1\le k<\sqrt{2n}\) and let \(n\ge r_1>\cdots>r_k>r_{k+1}=0\) and \(0=c_0<c_1<\cdots <c_k\le n\). These numbers define the Young diagram \(\Lambda \) of type k which, for \(i=1,\ldots ,k\), has \(c_i-c_{i-1}\) rows with \(r_i\) cells and \(r_i-r_{i+1}\) columns with \(c_i\) cells, with partition and conjugate partition

$$\begin{aligned} \lambda =\left( r_1^{c_1-c_0},\ldots ,r_k^{c_k-c_{k-1}}\right) ,\quad \lambda ^*=\left( c_k^{r_k-r_{k+1}},\ldots ,c_1^{r_1-r_2}\right) . \end{aligned}$$

Note that \(|\Lambda |=\sum _{i=1}^k(c_i-c_{i-1})r_i=\sum _{i=1}^k(r_i-r_{i+1})c_i\) is not necessarily equal to n, but any diagram with \(|\Lambda |=n\) does arise that way for a unique choice of type k and such \(r_i\) and \(c_j\).

Let now n, f, \(f^*\) be given. Fix any \(1\le k<\sqrt{2n}\). We reduce the problem of finding a diagram \(\Lambda \) with \(|\Lambda |=n\) of type k with minimum \(f(\lambda )+f^*(\lambda ^*)\) to finding a shortest directed path in a directed graph D where each edge has a length. We construct D as follows.

There are two vertices st, and vertices labeled by quadruples of integers \((i,c_i,r_{i+1},n_i)\) for \(0\le i\le k\), with \(1\le c_i,r_i,n_i\le n\) for \(1\le i\le k\), \(c_0=n_0=r_{k+1}=0\), and \(n_k=n\).

There are edges \([s,(0,0,r_1,0)]\) for \(1\le r_1\le n\) and edges \([(k,c_k,0,n),t]\) for \(1\le c_k\le n\), all of length 0, and there are edges \([(i-1,c_{i-1},r_i,n_{i-1}),(i,c_i,r_{i+1},n_i)]\) for \(1\le i\le k\), \(c_i>c_{i-1}\), \(r_{i+1}<r_i\), \(n_i=n_{i-1}+(c_i-c_{i-1})r_i\), of length \((c_i-c_{i-1})f(r_i)+(r_i-r_{i+1})f^*(c_i)\).

Consider any directed path from s to t in D, which by the definition of D looks like

$$\begin{aligned}&s\longrightarrow (0,c_0=0,r_1,n_0=0)\longrightarrow (1,c_1,r_2,n_1)\longrightarrow \cdots \cdots \\&\longrightarrow (k,c_k,r_{k+1}=0,n_k=n)\longrightarrow t. \end{aligned}$$

By definition of D, we have \(0=c_0<c_1<\cdots <c_k\le n\) and \(n\ge r_1>\cdots>r_k>r_{k+1}=0\), giving a Young diagram \(\Lambda \) of type k as explained above, with partition and conjugate partition

$$\begin{aligned} \lambda =\left( r_1^{c_1-c_0},\ldots ,r_k^{c_k-c_{k-1}}\right) ,\quad \lambda ^*=\left( c_k^{r_k-r_{k+1}},\ldots ,c_1^{r_1-r_2}\right) . \end{aligned}$$

Moreover, we have \(|\Lambda |=\sum _{i=1}^k(c_i-c_{i-1})r_i=n_k=n\), and the length of the path is

$$\begin{aligned} \sum _{i=1}^k(c_i-c_{i-1})f(r_i)+(r_i-r_{i+1})f^*(c_i)=f(\lambda )+f^*(\lambda ^*)\ . \end{aligned}$$

Conversely, it is clear that any diagram \(\Lambda \) with \(|\Lambda |=n\) of type k gives such a directed path, of length \(f(\lambda )+f^*(\lambda ^*)\). So a shortest \(s-t\) path gives an optimal Young diagram of type k.

Now, the number of vertices of D is bounded by \(2+2n+(k-1)n^3=O(n^{3.5})\) and hence by a polynomial in n. So a shortest directed path from s to t in D can be obtained in polynomial time, see, e.g., [2], by the following simple algorithm. For \(i=1,\ldots ,k\), compute for every vertex \(v=(i,c_i,r_{i+1},n_i)\) the length of a shortest \(s-v\) path and an edge entering it on such a shortest path, using the values already computed for \(i-1\), and then do the same for t.

Now, repeat the above procedure for \(k=1,\ldots ,\lfloor \sqrt{2n}\rfloor \) and output the best diagram. \(\square \)

As a simple example, for \(n=2\) and \(k=1\), the directed graph has exactly two \(s-t\) paths,

$$\begin{aligned}&s{\mathop {\longrightarrow }\limits ^{0}}(0,0,1,0) {\mathop {\longrightarrow }\limits ^{2f(1)+f^*(2)}}(1,2,0,2){\mathop {\longrightarrow }\limits ^{0}}t\ , \quad \text{ of } \text{ length }\quad 2f(1)+f^*(2), \\&s{\mathop {\longrightarrow }\limits ^{0}}(0,0,2,0) {\mathop {\longrightarrow }\limits ^{f(2)+2f^*(1)}}(1,1,0,2){\mathop {\longrightarrow }\limits ^{0}}t\ , \quad \text{ of } \text{ length }\quad f(2)+2f^*(1), \end{aligned}$$

which correspond to the two diagrams \(\Lambda \) and their partitions \(\lambda =(1^2)\) and \(\lambda =(2)\), respectively.

We note that the above proof in fact shows that we can solve in polynomial time the more refined problem where we search for a best diagram among those of a prescribed type k.