Matsushita's Blog

About LinkedList class in Java

What’s LinkedList

The LinkedList class implements the List interface. The structure is Doubly-linked list in java, each node has next node and previous node.

Time Complexity

add(E e) function

This function takes O(1) time. This is because, we only have to reconnect specific nodes.

E remove(int index) function

This function takes O(1) time as well as add(E e) function.

E get(int index) function

This function takes O(N). This is because, we have to traverse the list from first node or last node to target node. we cannot access the node with index.