Permutations by swapping: Difference between revisions
Content added Content deleted
mNo edit summary |
|||
Line 1,651: | Line 1,651: | ||
johnsontrotter(1,4) |
johnsontrotter(1,4) |
||
</lang> |
</lang> |
||
Recursive (note this uses memory of roughtly (n+1)! bytes, where n is the number of elements, in order to store the accumulated permutations in a list, and so the iterative solution is to be preferred for larger numbers of elements): |
|||
Recursive: |
|||
<lang julia> |
<lang julia> |
||
function johnsontrotter(low, high) |
function johnsontrotter(low, high) |