【发布时间】:2015-04-24 09:41:30
【问题描述】:
我正在研究大 O 表示法,我想找到我从 Project Euler 解决的数学问题的大 O 表示法。
total
for x (0..9){
for y (0..9){
for z(0..9){
if(some_condition == true){
total = total + permute(x,y,z)
}
}
} }
print total
由于有 3 个循环,我的猜测是 O(N^3),但我不确定
【问题讨论】:
-
由于循环直到恒定值,对我来说复杂性似乎是置换函数的复杂性。
-
O(1)。没有变量输入。
-
应该
for x (0...9)是for x (0...N)?
标签: algorithm big-o complexity-theory computer-science