I usually use the recursive algorithm as follows in Python:
def permutate(array, t, n):
if t == n:
for i in range(n):
print array[i]
return
for j in range(t,n):
flag = 1
for r in range(t,j):
if array[r] == array[j]:
flag = 0
break
if flag == 0:
continue
else:
array[j],array[t] = array[t],array[j]
permutate(array,t+1,n)
array[j],array[t] = array[t],array[j]
This one is neat. But I hope to find a convenient, non-recursive algorithm to do full permutation with repetitive elements?