【发布时间】:2017-11-24 13:15:38
【问题描述】:
for(int i = 0; i < n; i++) {
for(int j = 0; j < i; j++) {
O(1);
}
}
这里的函数是n * (n+1) / 2,但是如果外循环条件是i < log(n)呢?我对相互关联的循环有疑问。
【问题讨论】:
-
如果您将
n替换为其他内容,只需将n * (n+1) / 2中的每个n替换为相同的内容即可。这似乎归结为对基本代数缺乏了解(或暂时的精神失误)。
标签: algorithm performance notation