Is there a generator function f(i,j,n) that returns, in deterministic constant time and space, the ith element (0<=i<n) of the jth permutation (0<=j<n!) of the first n integers? If so, how does it work? If not, can I see a disproof?
This question is related to this one: Create a random permutation of 1..N in constant space However, in this case, we want to be able to generate every permutation, depending on our choice of j, not just a particular or arbitrary one.
It's also related to this one: Random access random permutations (In fact, it's probably exactly the sort of thing the author of that question would have liked to have, though I can't be sure this is not more specific and constrained. In any case, I am not interested in parallelization.)
If it IS possible, then I also would like to know if we can eliminate the parameter j (since its length is O(n)) and just generate a permutation chosen uniformly at random without having to name it first.
If it is NOT possible, then I wonder if it's possible to probabilistically (but still in deterministic linear-time and constant space) generate a uniformly chosen permutation. For instance, a method that produces a uniformly chosen sequence which happens to also be a permutation >1% of the time.
I am asking this question because all of the methods I know for generating permutations require either storing the range of values to be permuted explicitly, or at least storing all the numbers which have been generated so far.