问题
I wanted to know the time complexity of the next_permutation function. Can I view its code too ?
回答1:
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
.
来源:https://stackoverflow.com/questions/4972470/what-is-the-time-complexity-of-stdnext-permutation-function-in-c