From: Are there any better methods to do permutation of string?
what is the complexity of this function???
void permute(string elems, int mid, int en
Without looking too deeply at your code, I think I can say with reasonable confidence that its complexity is O(n!). This is because any efficient procedure to enumerate all permutations of n distinct elements will have to iterate over each permutation. There are n! permutations, so the algorithm has to be at least O(n!).
Edit:
This is actually O(n*n!). Thanks to @templatetypedef for pointing this out.