How is LinkedList's add(int, E) of O(1) complexity?

前端 未结 4 518
[愿得一人]
[愿得一人] 2020-12-29 20:54

From the linked-list tag wiki excerpt:

A linked list is a data structure in which the elements contain references to the next (and optionally the pr

4条回答
  •  情深已故
    2020-12-29 21:46

    The operation of linking the new node to any node is O(1) but the operation of finding (helps to the loop) the concerned index is definitely O(n).

    There is no magic ;)

提交回复
热议问题