Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
675 views
in Technique[技术] by (71.8m points)

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...