As far as I can tell, std::next_permutation algorithm runs in O(n!) time. Can anyone explain why that is? Or if I am even right about it?
Here is the code I am running it in, trying to count the number of permutations until the given array, of size n, has been sorted:
int permutationSort(int a[], int n)
{
int count = 0;
while (next_permutation(a, a + n))
{
count++;
}
return count;
}