3 ms·
linkedlists in java are bad. one of the benefits of a linkedlist is having the ability to remove an element from a list in O(1) by having reference to an item
by waynesonfire 4y ago
linkedlists in java are bad.
one of the benefits of a linkedlist is having the ability to remove an element from a list in O(1) by having reference to an item that is stored in the list. This is allowed since a linked list node can remve itself in constant time. This is a common pattern in linked lists used in C code for example.
javas linkedlists don't allow for this benefit. since in java you have to perform a search for the node to be removed and pay a O(n) penalty on a O(1) operation.