3 ms·
This article doesn't go over my favorite reason why Linked Lists are bad. Their main use case is that you can insert into the middle in constant time, right? We
by tobiasSoftware 4y ago
This article doesn't go over my favorite reason why Linked Lists are bad. Their main use case is that you can insert into the middle in constant time, right? Well, how do you find the insertion point? If your answer is anything algebraic, then I've got bad news for you: inserting into the middle might be constant time, but getting to the insertion point will be linear time.
Really, the only use case for linked lists is if direct pointers to elements are cached somewhere, and in that case you are probably using a map anyway. IMO linked lists should be replaced with an ordered map for this reason.
- LorenPechtel 4y agoIf you have an unordered list finding the spot is linear time anyway. That being said, the cases where a linked list is better than an array are very low these days.