What is the time complexity of the std :: next_permutation () function in C ++?

I wanted to know the time complexity of the next_permutation function. Can I view its code?

+6
c ++ stl
Feb 11 '11 at 18:05
source share
1 answer

See http://www.sgi.com/tech/stl/next_permutation.html :

Linear. Maximum (last - first) / 2 swaps.

To see the source code, just browse the STL header files for your system. On a Unix-like system, you probably need to search somewhere like /usr/include/c++/4.1.2/bits/stl_algo.h .

+11
Feb 11 '11 at 18:07
source share



All Articles