Given the list of elements, is there a shuffling algorithm that ensures that in the end the selected half will be on one side and the rest on the other?
Example: {4, 3, 10, 7, 2, 9, 6, 8, 1, 5}
Given the above, I would like to have a mixing algorithm that ultimately moves marked from left to left, although the algorithm itself has no idea what is and is not “marked”.
{4, 3, 10, 7, 2, 9, 6, 8, 1, 5}
X X X X X
Valid results are:
{4, 10, 9, 6, 1, 3, 7, 2, 8, 5}
{1, 9, 10, 4, 6, 2, 8, 5, 7, 3}
{1, 4 , 9, 10, 6, 3, 7, 5, 8, 2}, etc.
Difficulty: The algorithm should not use random numbers to mix content, it should be an iterative process. So Fisher Yates doesn't work.