algorithm for permutation with swap() and recursion