Step 1: Fix element 1 at index 0, permute rest [2,3]
[1, 2, 3] ↑ at index 0
Why: Start with first element fixed to generate permutations of remaining
Step 2: Fix element 2 at index 1, permute rest [3]
[1, 2, 3] ↑ at index 1
Why: Fix second element to generate permutations of last element
Step 3: Add permutation [1, 2, 3] to results
[1, 2, 3]
Why: Reached last element, record current order
Step 4: Swap elements at index 1 and 2 to get [1, 3, 2]
[1, 3, 2] ↑ at index 1
Why: Change order to explore new permutation
Step 5: Add permutation [1, 3, 2] to results
[1, 3, 2]
Why: Reached last element, record current order
Step 6: Backtrack swap to restore [1, 2, 3]
[1, 2, 3] ↑ at index 0
Why: Restore original order to try next first element
Step 7: Swap elements at index 0 and 1 to get [2, 1, 3]
[2, 1, 3] ↑ at index 0
Why: Change first element to 2 and permute rest
Step 8: Fix element 1 at index 1, permute rest [3]
[2, 1, 3] ↑ at index 1
Why: Fix second element to generate permutations of last element
Step 9: Add permutation [2, 1, 3] to results
[2, 1, 3]
Why: Reached last element, record current order
Step 10: Swap elements at index 1 and 2 to get [2, 3, 1]
[2, 3, 1] ↑ at index 1
Why: Change order to explore new permutation
Step 11: Add permutation [2, 3, 1] to results
[2, 3, 1]
Why: Reached last element, record current order
Step 12: Backtrack swap to restore [2, 1, 3]
[2, 1, 3] ↑ at index 0
Why: Restore original order to try next first element
Step 13: Swap elements at index 0 and 2 to get [3, 1, 2]
[3, 1, 2] ↑ at index 0
Why: Change first element to 3 and permute rest
Step 14: Fix element 1 at index 1, permute rest [2]
[3, 1, 2] ↑ at index 1
Why: Fix second element to generate permutations of last element
Step 15: Add permutation [3, 1, 2] to results
[3, 1, 2]
Why: Reached last element, record current order
Step 16: Swap elements at index 1 and 2 to get [3, 2, 1]
[3, 2, 1] ↑ at index 1
Why: Change order to explore new permutation
Step 17: Add permutation [3, 2, 1] to results
[3, 2, 1]
Why: Reached last element, record current order
Step 18: Backtrack swap to restore [3, 1, 2]
[3, 1, 2]
Why: Restore original order after exploring all permutations
Result: [1, 2, 3]
[1, 3, 2]
[2, 1, 3]
[2, 3, 1]
[3, 1, 2]
[3, 2, 1]