I am solving the following problem, motived by combinatorial optimization sampling proces.
I have restriction (0,1) matrix to restrict which item (column index) can be on current position (row index) at permutations. For example: 4x4 case (4 position permutations)
1 1 1 0
1 1 0 1
1 0 1 1
0 1 1 1
So, on position 4 (4th row at restriction matrix) is not allowed items 1, for example.
This restrictions produce the following list of possible permutations (earch row is one possible permutation):
1 2 3 4
1 2 4 3
1 4 3 2
2 1 3 4
2 1 4 3
2 4 1 3
3 1 4 2
3 2 1 4
3 4 1 2
I am looking for algorithm to check if any sub-permutation, which is represented by first N < 4 positions, may correspond to any of possible permutation or not, without need to avaluate all possible permutations.
For example sub-permutation [1 2 3] is OK, but sub-permutation [3 4 2] is not.