Step 1: Start at index 0, swap element at 0 with 0 (no change)
[1, 2, 3]
Why: Begin permutations by fixing first element and permuting the rest
Step 2: Move to index 1, swap element at 1 with 1 (no change)
[1, 2, 3]
Why: Fix second element and permute the last element
Step 3: Move to index 2, reached end, record permutation [1, 2, 3]
[1, 2, 3]
Why: One full permutation is ready to save
Step 4: Backtrack to index 1, swap element at 1 with 2
[1, 3, 2]
Why: Change second element to next option to generate new permutations
Step 5: Move to index 2, reached end, record permutation [1, 3, 2]
[1, 3, 2]
Why: Another full permutation is ready to save
Step 6: Backtrack to index 0, swap element at 0 with 1
[2, 1, 3]
Why: Change first element to next option to generate new permutations
Step 7: At index 1, swap element at 1 with 1 (no change)
[2, 1, 3]
Why: Fix second element and permute the last
Step 8: At index 2, reached end, record permutation [2, 1, 3]
[2, 1, 3]
Why: Save this permutation
Step 9: Backtrack to index 1, swap element at 1 with 2
[2, 3, 1]
Why: Change second element to next option
Step 10: At index 2, reached end, record permutation [2, 3, 1]
[2, 3, 1]
Why: Save this permutation
Step 11: Backtrack to index 0, swap element at 0 with 2
[3, 2, 1]
Why: Change first element to last option
Step 12: At index 1, swap element at 1 with 1 (no change)
[3, 2, 1]
Step 13: At index 2, reached end, record permutation [3, 2, 1]
[3, 2, 1]
Why: Save this permutation
Step 14: Backtrack to index 1, swap element at 1 with 2
[3, 1, 2]
Why: Change second element to last option
Step 15: At index 2, reached end, record permutation [3, 1, 2]
[3, 1, 2]
Why: Save this permutation
Result: [1, 2, 3]
[1, 3, 2]
[2, 1, 3]
[2, 3, 1]
[3, 1, 2]
[3, 2, 1]