3 ms·
Feature not a big in my book. A linked list is almost never the right answer. Certainly shouldn't be the default.
by TylerE 3y ago
Feature not a big in my book. A linked list is almost never the right answer. Certainly shouldn't be the default.
- hajile 3y ago> A linked list is almost never the right answer. And yet a subset of the linked list called a tree is usually the right answer to problems.
- TylerE 3y agobecause it avoids all the pathological worse case performance unless you get insanely unlucky with the order the data is inserted... and even then you can do a rebalance if you're that concerned about it.
- dleslie 3y agoIt depends on how you approach solving problems, and what the problem is. In the contrived example, a linked list is clearly a terrible option for manipulating a sorted set of integers. Modern computers can slice and dice contiguous integers with vectorized routines, and those benefits are lost with linked lists that are storing their data haphazardly across the heap. If your problem space is best defined with contiguously-stored numbers, then for sure, don't use linked lists. Most lisps will happily provide you with vectors and arrays for these use cases.