|
|
|
|
|
by worik
401 days ago
|
|
I am working on a code base, that among its many glories and poo balls every list is a doubly linked list. Stop! If you are using a doubly linked list you (probably) do not have to, or want to. There is almost no case where you need to traverse a list in both directions (do you want a tree?) A doubly linked list wastes memory with the back links that you do not need. A singly linked list is trivial to reason about: There is this node and the rest. A doubly linked list more than doubles that cognitive load. Think! Spend time carefully reasoning about the data structures you are using. You will not need that complicated, wasteful, doubly linked list |
|
But you might need to remove a given element that you have a pointer to in O(1), which a singly linked list will not do