【发布时间】:2016-11-08 12:03:14
【问题描述】:
为什么是时间复杂度
function (n)
{
//this loop executes n times
for( i = 1 ; i <= n ; i + + )
//this loop executes j times with j increase by the rate of i
for( j = 1 ; j <= n ; j+ = i )
print( “*” ) ;
}
它的运行时间是n*(n^1/2)=n^3/2
所以,O(n^3/2)
请用数学步骤解释。
提前谢谢你。
【问题讨论】:
标签: data-structures time-complexity nested-loops