开发者

what is the time complexity of std::next_permutation() function in c++?

开发者 https://www.devze.com 2023-02-10 13:08 出处:网络
I wanted to know the time complexity of the next_permutation function.开发者_StackOverflow Can I view its code too ? See http://www.sgi.com/tech/stl/next_permutation.html:

I wanted to know the time complexity of the next_permutation function.开发者_StackOverflow 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消