Operation Name | Operation Type | Description | Worst Time Complexity |
---|---|---|---|
Push | Insertion | Adds item to the collection end | O(1) |
Unshift | Insertion | Adds item to the collection start | O(1) |
Pop | Deletion | Adds item to the collection end | O(n) |
Shift | Deletion | Adds item to the collection start | O(1) |
Get | Search | Search item in the collection by index | O(n) |
Set | Search/Insert | Search item in specific position and replace its value | O(n) |
Insert | Search/Insert | Search item in specific position and set item as its next value, reference old next as item`s next. | O(n) |
Remove | Search/Remove | Remove item in a specific position connection directly the two immediate neighbors. | O(n) |
Remove | Search/Insert | Invert all items in a given collection. | O(n) |
It has a time complexity of O(1) because it doesn`t need to iterate trought the links.
Has a time complexty of O(n) because it has to search the last item linearly in order to remove the link and move the 'tail' pointer to the previous link.
Search items either by their indexes, returning their value. Has a time complexty of O(n) because it has to iterate each node linearly beginning from head until the requested item.
Search item in specific position and replace its value. Has a time complexty of O(n) because it has to iterate each node linearly beginning from head until the requested item and then replacing the value of requested node with O(1) time complexity. Removing non dominant operation we have O(n).
Search item in specific position and then set as next of the previous one and set current position item as next. Has a time complexity of O(n) because it has to iterate each node linearly beggining from head until the requested index position.
Remove item in a specific position connection directly the two immediate neighbors. Has a time complexity of O(n) because it has to iterate each node linearly beggining from head until the requested index position.
Invert all items in a given collection. Has a time complexity of O(n) because it has to iterate the whole collection linearly to reorder the nodes.