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

醉酒当歌 提交于 2020-01-10 03:58:05

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!