相关疑难解决方法(0)

Javascript中unshift()与push()的时间复杂度

我知道Javascript中的unshift()和push()方法有什么区别,但我想知道时间复杂度有什么不同?

我想push()方法是O(1),因为你只是在数组末尾添加一个项目,但我不确定unshift()方法,因为,我想你必须"移动"所有其他现有的元素向前,我想是O(log n)或O(n)?

javascript arrays time complexity-theory push

62
推荐指数
4
解决办法
2万
查看次数

标签 统计

arrays ×1

complexity-theory ×1

javascript ×1

push ×1

time ×1