5

Suppose we have a sequence with $n$ distinct items, $\mbox{item}_0, \dots, \mbox{item}_{n-1}$ and $n$ positions $p_0, \dots, p_{n-1}$. The only restriction is that for $\mbox{item}_i$, it can only appear at its neighbor positions with at most distance of $d$, note that here $d$ is small, generally $d \le 5$. We have for $\mbox{item}_i$, it can appear at $[p_{i-d}, p_{i+d}], 0 \le i-d, i+d\le n$. I got two questions:

  1. Is there any algorithms that is fast to generate all sequences?

  2. What is the number of all possible sequences?

This question is a simplified version of the question Permutations with restrictions on item positions.

hddmss
  • 151
  • 4

0 Answers0