For each array position it is known if position filled or not.
How efficiently pick one free position with uniform probability?
That task happen during implementation of AI by Monter-Carlo method for board game.
I have in mind:
Is it possible uniformly pick free position with only one scan?
From my intuition this algorithm produce biased solution toward clustered arrays:
What if for each free position picking generate random permutation without cycles and travel across all elements by uniformly choosing index and recursively applying permutation until free position was found? I don't know if this algorithm leads to uniform picking. I don't know how to represent computationally efficient subset of permutations. This way may produce one pass solution...
Reservoir sampling can be used to uniformly pick a "free position with only one scan".