且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么数组插入的时间复杂度是O(n)而不是O(n + 1)?

更新时间:2021-07-26 04:32:11

任何一个O(n)函数也是O(n + 1),反之亦然。低阶字词实际上会被忽略,因此+1不会产生任何有意义的作用。

Any function that is O(n) is also O(n+1), and vice versa. Lower-order terms are essentially ignored, so the +1 doesn't contribute anything meaningful.