Algorithm to generate all possible permutations of a list?
Posted
by LLer
on Stack Overflow
See other posts from Stack Overflow
or by LLer
Published on 2010-04-26T01:52:19Z
Indexed on
2010/04/26
1:53 UTC
Read the original article
Hit count: 245
algorithms
|list
Say I have a list of n elements, I know there are n! possible ways to order these elements. What is an algorithm to generate all possible orderings of this list? Example, I have list [a, b, c]. The algorithm would return [[a, b, c], [a, c, b,], [b, a, c], [b, c, a], [c, a, b], [c, b, a]].
I'm reading this here http://en.wikipedia.org/wiki/Permutation#Algorithms_to_generate_permutations
But Wikipedia has never been good at explaining. I don't understand much of it.
© Stack Overflow or respective owner