3
說我有K中嵌套在以下方式循環:任意嵌套循環的大O分析?
for a = 1 to n:
for b = 1 to n-a:
for c = 1 to n-a-b:
for d = 1 to n-a-b-c:
O(1)
的任意K,但這些循環「共享」相互n次迭代的極限,所有k是大O的複雜性還是O(n^k)?或者它低於那個訂單?
編輯:What is the Big-O of a nested loop, where number of iterations in the inner loop is determined by the current iteration of the outer loop?的確在提出類似的問題,但它並沒有要求(也沒有答覆地址)嵌套的其他級別是否會改變任何東西。
德米特里的答案很好地解釋了我的看法。
可能重複[什麼是嵌套循環的Big-O,其中內循環中的迭代次數由外循環的當前迭代決定?](http://stackoverflow.com/questions/362059 /什麼-是最大鄰對的一嵌套循環-其中-數的迭代 - 內式內環路) – Vache