Permutations
Learn Permutations (Recursion & Backtracking, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Generating All Orderings A set of n distinct elements has n! permutations. Backtracking builds each one by choosing an UNUSED element at each position, recursing, then un-choosing it (backtrack) to try the next option - a used[] array tracks which elements are already placed in the current permutation.