Step 1: Start with 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 remaining elements
Step 3: Move to index 2, reached end, record permutation [1, 2, 3]
[1, 2, 3]
Why: Base case: one permutation completed
Step 4: Backtrack to index 1, swap element at 1 with 2
[1, 3, 2]
Why: Swap to create new permutation branch
Step 5: Move to index 2, reached end, record permutation [1, 3, 2]
[1, 3, 2]
Why: Base case: another permutation completed
Step 6: Backtrack to index 0, swap element at 0 with 1
[2, 1, 3]
Why: Change first element 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 rest
Step 8: At index 2, reached end, record permutation [2, 1, 3]
[2, 1, 3]
Why: Record new permutation
Result: [1, 2, 3]
[1, 3, 2]
[2, 1, 3]
[2, 3, 1]
[3, 1, 2]
[3, 2, 1]