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

This is because the article that you are reading considered “getting to that index” as a separate operation. The article assumes that you are already at the index you wish to perform add(int, E).

To conclude:

Insert or Remove operation = O(1)

Finding node at nth index = O(n)

Leave a Comment

tech