【发布时间】:2021-11-04 05:22:55
【问题描述】:
最近开始使用这个所以需要你的帮助,假设你已经嵌套了如下所示的 for 循环,范围从 1 到 n,如何根据 Big O、Theta、Omega 计算相同的运行时间?
for(i=1; i<n; i++) {
for(j=1; j<n; j++) {
//some piece of code
}
}
【问题讨论】:
-
你能想出一种方法来计算
//some piece of code被执行的确切次数吗? -
实现它并尝试使用
n的不同值。
标签: algorithm performance timing notation