Oct. 15, 2013
1:40 a.m.
[MRAB]
I can see that one disadvantage of my algorithm is that the worst-case storage requirement is O(n^2) (I think). This is because the set of first items could have N members, the set of second items could have N-1 members, etc. On the other hand, IMHO, the sheer number of permutations will become a problem long before the memory requirement does! :-)
My rewrite is O(N) space (best and worst cases). I _think_ yours is too, but I understand my rewrite better by now ;-) Each element of the iterable appears in exactly one ENode: the `ehead` list is a partitioning of the input iterable.