写出for (i=n; i>0; i/=3); 的时间复杂度

来源:学生作业学帮网 编辑:学帮网 时间:2024/05/16 14:53:11

写出for (i=n; i>0; i/=3); 的时间复杂度

O(log n).
n n/3 n/3的2次方 n/3的3次方 ... ...n/3的x次方(终点为0)
可以看到运行的次数取决于以3为底,n的对数.