4 ms·
In languages that can mutate data structures using side-effects, linked lists are rarely the best choice of data structure. Note, for example, that Python and
by sah 18y ago
In languages that can mutate data structures using side-effects, linked lists are rarely the best choice of data structure. Note, for example, that Python and Ruby have built-in array-based lists, but no linked lists. Similar structures are the default for lists in C++, Java, and C#.
That said, I'm pretty sure people use linked lists a lot in Common Lisp.
- astine 18y agoMemory usage and random access times are far better in arrays, but for dynamic resizing, deletion, insertion, appending, and splitting, that is, operations that deal with data structure rather than the content, lists are far superior to arrays. I used to hand-code linked lists back when I used C/C++ heavily. They have some very significant advantages for modeling certain kinds of data.
- sah 18y agoI didn't mean to imply that linked lists aren't a useful data structure, just that arrays and array-based lists are well suited to an apparently wider range of problems.