3 ms·
The short answer is that with a singly-linked list, you can easily add items to one end (conceptually, typically the front end.) Then if other code has referenc
by massysett 4y ago
The short answer is that with a singly-linked list, you can easily add items to one end (conceptually, typically the front end.) Then if other code has references to the older parts of the list, they’re still valid.
A great explanation of this is in “Practical Common Lisp”:
https://gigamonkeys.com/book/they-called-it-lisp-for-a-reason-list-processing.html https://gigamonkeys.com/book/they-called-it-lisp-for-a-reaso...
- sidlls 4y agoBut then there are cache locality issues, etc. Algorithmic runtime performance in practice rarely matches the basic big-O analysis taught in CS classes. Case in point: for small cardinality data in practice it’s often (or at least occasionally) faster to use a linear time search algorithm on a fixed length array than to put it, say, in a tree, map, etc. that is big-O “better”.