4 ms·
I still can't see the real usefulness of linked lists, the idea of having a data container that doesn't have a transparent indexing algorithm sounds ill-advised
by jokoon 12y ago
I still can't see the real usefulness of linked lists, the idea of having a data container that doesn't have a transparent indexing algorithm sounds ill-advised.
Linked lists should be named "linked graphs" instead.
There is so much relevant science to learn about CPU caches, than there is about using a container which is based on nested pointer indirections.
- agentultra 12y agoThe only thing I can think of is when your algorithm is building the sequence of items whose length cannot be precalculated. For lists of a certain size you might be able to save over the amortized cost of calling realloc on an array. Just have to follow the data and watch how its used and build your program to provide the simplest flow.
- noselasd 12y agoNote that the links in a linked can be in-line with the contained data (aka. intrusive pointers). Albeit quite uncommon, they don't need to be pointers/references at all, but indexes.
- jdmichal 12y agoIf you're going to change the name, "unary trees" makes a lot more sense. "Linked graph" does not imply the 1-child-per-node linearity requirement of a linked list.