permutation, recursion and swap, like depth first traversal