2014-11-14 91 views
0

您能否告訴我在Python中的「itertools.permutation」模塊中,permutations()的複雜性是什麼?itertools.permutations的複雜性

我正在練習和學習python,並感謝您的任何幫助。

+3

你必須研究[C的源代碼](https://hg.python.org/cpython/file/e106d9368bff/Modules/itertoolsmodule.c#l2527)。 – 2014-11-14 22:20:24

回答

-1

它是O(1),因爲它只是返回一個對象,它的next方法在每次調用時會返回不同的排列方式。參數permutations的大小不會影響創建該對象所用的時間。

+0

沒關係,那麼這個可迭代的解包複雜度是多少 – 0TTT0 2017-12-18 22:54:01