Print all the permutations of a string in C

前端 未结 8 1475
自闭症患者
自闭症患者 2020-11-29 04:06

I am learning backtracking and recursion and I am stuck at an algorithm for printing all the permutations of a string. I solved it using the bell algorithm for permutation b

8条回答
  •  甜味超标
    2020-11-29 04:55

    Pseudo code:

    String permute(String a[])
    {
      if (a[].length == 1)
         return a[];
      for (i = 0, i < a[].length(); i++)
        append(a[i], permute(a[].remove(i)));
    }
    

提交回复
热议问题