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
Ignoring the print, the recurrence relation satisfied is
T(n) = n*T(n-1) + O(n)
If G(n) = T(n)/n! we get
G(n) = T(n)/n!
G(n) = G(n-1) + O(1/(n-1)!)
which gives G(n) = Theta(1).
G(n) = Theta(1)
Thus T(n) = Theta(n!).
T(n) = Theta(n!)
Assuming that the print happens exactly n! times, we get the time complexity as
n!
Theta(n * n!)