Skip to main content

Permutations

Definition​

The Permutations Algorithm is a method used to generate all possible arrangements of elements in a set

Practice​

generate_permutations(elements, current_permutation, permutations):
if length(current_permutation) == length(elements):
permutations.append(current_permutation)
return

for each element in elements:
if element not in current_permutation:
new_permutation = current_permutation + [element]
generate_permutations(elements, new_permutation, permutations)