Time complexity of deletion in a linked list

后端 未结 2 539
野的像风
野的像风 2021-02-02 16:02

I\'m having a bit of trouble understanding why time complexity of link lists are O(1) according to this website. From what I understand if you want to delete an element surely y

2条回答
  •  梦毁少年i
    2021-02-02 16:25

    Your are correct.

    Deletion:

    1.If pointer is given in this case Time Complexity is O(1).

    2.You DON'T have pointer to the node to be deleted(Search and Delete). In this case Time Complexity is O(n).

提交回复
热议问题