Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
For (int i=1; i <=n;i/=2){ System.out.println(i); }
对于上述编码的时间复杂度,是 ot log (n) 吗?
谢谢!
如果n > 0:它的时间复杂度是O(∞)因为循环永远不会结束
n > 0
O(∞)
if n <= 0: 它的时间复杂度是O(1) 因为循环不会被执行
n <= 0
O(1)