Select $k$ non overlapping segments from $n$ points

487 Views Asked by At

We have $n$ points , say labeled from $1$ to $n$. We have to select $k$ segments from it so that no $2$ overlap.

One possible solution would be by using a recurrence relation $f(k,n)=\sum i*f(k-1,n-i) $.

Where I have chosen first segment ending at $i$ and chose other segments from remaining part in array.

Does there exist a closed form? If there does not what would the most time efficient way to compute this? In other words how can we simplify it further?

1

There are 1 best solutions below

2
On BEST ANSWER

You can specify a segment by its first point and last point. The entire set of $k$ intervals can then be specified by a sequence $\langle a_1,b_1\ldots,a_k,b_k\rangle$ in $[n]$ such that $a_m\le b_m$ for $m=1,\ldots,k$ and $b_m<a_{m+1}$ for $m=1,\ldots,k-1$. Conversely, every such $2k$-tuple in $[n]$ determines a set of $k$ non-overlapping intervals.

Let $x_1=a_1-1$, $x_2=b_1-a_1$, $x_3=a_2-b_1-1$, and so on through $x_{2k}=b_k-a_k$: $x_{2i}=b_i-a_i$ for $i=1,\ldots,k$, and $x_{2i+1}=a_{i+1}-b_i-1$ for $i=1,\ldots,k-1$. Let $x_{2k+1}=n-b_k$. Then each $x_i$ is a non-negative integer, and

$$\sum_{i=1}^{2k+1}x_i=n-k\tag{1}\;.$$

Conversely, any solution to $(1)$ in non-negative integers yields a set of $k$ non-overlapping intervals, since it determines the numbers $a_i$ and $b_i$. This is a standard stars and bars problem: $(1)$ has

$$\binom{(n-k)+(2k+1)-1}{(2k+1)-1}=\binom{n+k}{2k}$$

solutions in non-negative integers.