Ram模型示例算法大哦 [英] Ram modle example algorithm big oh

查看:166
本文介绍了Ram模型示例算法大哦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

k = 0(1)

for i from0到n = o(n)



print i; o(n)

k = k + i; = o(n)



-



我尝试了什么:



k=0 (1)
for i from0 to n = o(n)

print i ; o(n)
k=k+i; = o(n)

-

What I have tried:

what i dont understand why the first statment is = 1 ? 

推荐答案

因为它的执行需要一个恒定的时间,即一个不依赖于 n的时间间隔
Because its execution requires a constant time, i.e. a time interval that does NOT depend on n.


首先,这段代码不正确Java!

First, this code is not correct Java !
引用:

我不明白为什么第一个陈述是= 1?

what i dont understand why the first statment is = 1 ?



(1)表示 k = 0 只执行一次。


这篇关于Ram模型示例算法大哦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆