Say you want to iterate over a sequence [0 to n] in a random order, visiting every element exactly once. Is there any way to do this in O(1) memory, i.e. without creati
No there is not, think about it, somewhere the program has to remember the places it has visited. If there is an iterator that can randomly access them all, the iterators internals would have to keep track of this somehow and you would still be using the memory.