Hacker News new | ask | show | jobs
by jokoon 4113 days 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.

3 comments

If 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.
The 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.

Note 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.