# Who invented the breadth-first permutation algorithm?

My initial problem was solved here. It is about enumerating all n-tuples of a permutation in a specific order.

The solution algorithm is very simple and I'm sure has been used before. However, I did not find any scientific references. Do you know it, or do you know how to search for it better?

The code itself:

def seq(n, k):
if (k == 0):
yield ()
return

for i in range(n+1):
for subseq in seq(i, k-1):
for j in range(k):
yield subseq[:j] + (i,) + subseq[j:]
if j != k-1 and subseq[j] == i:
break


Output for n=4, k=2:

00
10 01 11
20 02 21 12 22
30 03 31 13 32 23 33
40 04 41 14 42 24 43 34 44

-
 I'm not sure if this is on topic here, if not, please redirect me :) – mafutrct Sep 12 '12 at 12:01