I wanted to know the time complexity of the next_permutation function. Can I view its code too ?
See http://www.sgi.com/tech/stl/next_permutation.html:
Linear. At most (last - first) / 2 swaps.
To see the source code, just look in STL header files for your system. On a Unix-like system, you probably need to look somewhere like /usr/include/c++/4.1.2/bits/stl_algo.h.
/usr/include/c++/4.1.2/bits/stl_algo.h
2.1m questions
2.1m answers
60 comments
57.0k users